Skip to content

cloudbees-io/servicenow-poll-for-approval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

CloudBees action: ServiceNow change request poll for approval

Use this functionality to query an existing ServiceNow change request for approval.

Authentication methods

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.

Supported versions

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 and approval-field-value-rejected).

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

License

This code is made available under the MIT license.

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published