Query a ServiceNow change request for approval

2 minute read

Use this functionality to query an existing ServiceNow change request for approval. The user must provide:

  • Valid credentials (Basic authentication or OAuth authentication) and the ServiceNow host URL.

  • The cr-number auto-generated during change request creation.

  • At least one of the following two options to poll for these fields to reach the given values:

    • The current state of the change request (specified by state-field-value).

    • The value of the approval field in ServiceNow (specified by approval-field-value-approved and approval-field-value-rejected).

All CloudBees action repositories are listed at CloudBees, Inc. on GitHub.

Inputs

Inputs for querying a change request for approval are listed below.

Table 1. Input details
Change request model field Data type Required Description

url

String

Yes

The ServiceNow host URL.

username

String

Yes

The username for authentication.

password

String

Yes

The password for authentication.

client-id

String

Required only for OAuth-based authentication.

The unique identification number of the client.

client-secret

String

Required only for OAuth-based authentication.

The client secret for authentication.

cr-number

String

Yes

The unique number auto-generated during change request creation.

poll-interval

String

No

The polling interval, in minutes, for the action to periodically check the approval status in ServiceNow. Default is 3, and the maximum interval time allowed is 5760 minutes.

poll-duration

String

No

The maximum time duration, in minutes, for the action to continue polling for approval status in ServiceNow. Default is 60, and the maximum duration allowed is 5760 minutes.

state-field-value

String

Required if approval-field-value-approved and approval-field-value-rejected are not specified.

The value of the state field in ServiceNow. The action continues to poll until the state field in ServiceNow matches state-field-value.

approval-field-value-approved

String

Required if approval-field-value-rejected is specified.

The value of the approval field in ServiceNow which indicates that the change request is approved. The action continues to poll until the approval field in ServiceNow is either "approved" or "rejected".

approval-field-value-rejected

String

Required if approval-field-value-approved is specified.

The value of the approval field in ServiceNow which indicates that the change request is rejected. The action continues to poll until the approval field in ServiceNow is either "approved" or "rejected".

Usage examples

The following is an example payload for querying a change request for approval using OAuth-based authentication and both state and approval values:

- name: Query ServiceNow CR with state and approval fields uses: cloudbees-io/service-now-poll-for-approval@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ vars.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} client-id: ${{ secrets.MY_CLIENT_ID }} client-secret: ${{ secrets.MY_CLIENT_SECRET }} cr-number: "Unique ServiceNow-generated number" poll-interval: 5 poll-duration: 120 state-field-value: "Ready for deploy" approval-field-value-approved: approved approval-field-value-rejected: rejected

The following is an example payload for querying a change request for approval using basic authentication and the state value:

- name: Query ServiceNow CR with state field uses: cloudbees-io/service-now-poll-for-approval@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ vars.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} cr-number: "Unique ServiceNow-generated number" poll-interval: 3 poll-duration: 60 state-field-value: "Ready for deploy"

The following is an example payload for querying a change request for approval using OAuth-based authentication and approval values:

- name: Query ServiceNow CR with approval fields uses: cloudbees-io/service-now-poll-for-approval@v1 with: url: ${{ vars.SERVICENOW_URL }} username: ${{ vars.MY_SERVICENOW_USERNAME }} password: ${{ secrets.MY_SERVICENOW_PASSWORD }} client-id: ${{ secrets.MY_CLIENT_ID }} client-secret: ${{ secrets.MY_CLIENT_SECRET }} cr-number: "Unique ServiceNow-generated number" poll-interval: 15 poll-duration: 2000 approval-field-value-approved: approved approval-field-value-rejected: rejected