Use this functionality to query an existing ServiceNow change request for approval.
The ServiceNow action supports both basic and OAuth authentication methods to connect with ServiceNow.
-
Basic authentication: Provide a ServiceNow URL, a valid username, and a password to connect to the ServiceNow application.
-
OAuth authentication: In addition to a ServiceNow URL, a valid username, and a password, provide a ClientId and Client Secret, for generating a bearer access token with an expiration date. This method is more secure.
CloudBees has tested and supports the ServiceNow Xanadu release for use with these platform actions. Other versions of ServiceNow may work with the CloudBees platform, but they are not yet supported. If you are using another version of ServiceNow, submit a feature request with CloudBees Support.
The user must provide:
-
Valid credentials 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
andapproval-field-value-rejected
).
-
Inputs for querying a change request for approval are listed below.
Change request model field | Data type | Required | Description |
---|---|---|---|
|
String |
Yes |
The ServiceNow host URL. |
|
String |
Yes |
The username for authentication. |
|
String |
Yes |
The password for authentication. |
|
String |
Required only for OAuth-based authentication. |
The unique identification number of the client. |
|
String |
Required only for OAuth-based authentication. |
The client secret for authentication. |
|
String |
Yes |
The unique number auto-generated during change request creation. |
|
String |
No |
The polling interval, in minutes, for the action to periodically check the approval status in ServiceNow.
Default is |
|
String |
No |
The maximum time duration, in minutes, for the action to continue polling for approval status in ServiceNow.
Default is |
|
String |
Required if |
The value of the state field in ServiceNow.
The action continues to poll until the state field in ServiceNow matches |
|
String |
Required if |
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". |
|
String |
Required if |
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". |
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
This code is made available under the MIT license.
-
Learn more about using actions in CloudBees workflows.
-
Learn about the CloudBees platform.