Why do we need a ServiceNow Custom Stage in the Spinnaker CI/CD pipelines?

In today’s fast-paced world of software delivery business with high release cadence, organizations need to have the proper audit and approvals in place before releasing any applications into the production environments while using Spinnaker CI/CD pipelines. The release items need to undergo various testing and approvals processes before going into production and we need to have the proper “SignOff Approvals” from each and every release team member with approval authority. In order to have a smooth and continuous ongoing release process, we need to have a good System of Record – Ticketing (feedback) systems like ServiceNow, Jira, etc.

While the Spinnaker CD (Continuous Delivery) application makes life easier for the busy release teams handling production releases, integrating the Spinnaker with the ServiceNow application helps DevOps teams automate the ticketing/auditing of deployments and approval of CI/CD pipeline stages. Thus, we can have a much easier release process with all the required approvals in place.

In this blog, we will discuss how to use ServiceNow for production deployments using Spinnaker.

Steps for the Integration Process:

  1. Pre Requisites.
  2. Configuring Webhook in Service Now.
  3. Configuring ServiceNow Custom Stage in Spinnaker.
  4. Execution.

Pre Requisites:

ServiceNow Developer Account.

This blog assumes that the user has the “ServiceNow Developer” account created. If the user does not have the developer account, he can create one using the following steps: 

    1. Navigate to
    2. Sign in, if the user already has an account or click “Signup and Start building” to create a new account.
    3. After logging in, click the “Request Instance” option on the left side.
    4. Launch the new instance. It will take around 5 mins for the new instance to be created.
    5. Once the new instance is created, note down the following details for future reference:
      • Your instance URL
      • Username
      • Password

Configuring Spinnaker Webhook Listener in ServiceNow:

In ServiceNow, we need to create a Scripted Web Service. At a high level, this service performs the following actions:

  • Receives the Webhook from Spinnaker.
  • Processes the contents of the payload.

Below are the steps to create the Scripted Web Service in ServiceNow:

  • Search for Scripted REST APIs in the ServiceNow Navigator.
Search for Scripted REST APIs
Search for Scripted REST APIs
  • Create a new “Scripted Web Service” and give it a descriptive name e.g. SpinnakerWebhookListener.
Create a new Scripted Web Service
  • Click Submit and create the service.

Configuring ServiceNow Custom Stage in Spinnaker:

To create a ServiceNow custom stage, you can go to /home/spinnaker/.hal/default/profiles on Halyard pod and try to edit orca-local.yamlIn case a file with this name doesn’t exist, please create it. You need to add the following content in your orca-local.yaml file to generate a custom ServiceNow stage

– label: “Service Now: Wait for state”

					type: waitServiceNowState
enabled: true
description: Custom stage that waits for a specific state on a ServiceNow Issue
method: GET
   Authorization: Basic
   Content-Type: application/json
progressJsonPath: "result[0].state.display_value"
payload: ""
retryStatusCodes: -200
statusJsonPath: "result[0].state.display_value”
successStatuses: ${parameterValues['success']}
retryStatuses: ${parameterValue['retry']}
canceledStatuses: ${parameterValues['cancel']}
waitForCompletion: true

– label: ServiceNow Issue ID

					name: issue
description: "The Service Now issue ID"
type: string
defaultValue: ${Servicenow_issue}

– label: ServiceNow Success States

					name: success
description: "Service Now issue States that progress the pipeline, e.g,: In Verification, etc."
type: string
defaultValue: Assess

– label: ServiceNow Retry States

					name: retry
description: "Service Now issue states that Retry the stage e.g, New, etc."
type: string
defaultValue: New

– label: ServiceNow Termination States

					name: terminate
description: "ServiceNow issue states that terminate the pipeline, e.g, Done, etc."
type: string
defaultValue: Done

– label: ServiceNow Canceled States

					name: cancel
description: "ServiceNow issue states that cancel the pipeline e.g,: Closed, etc."
type: string
defaultValue: Closed

The Custom Stage uses the following labels as a parameter:

  • ServiceNow Issue ID: This is the “ServiceNow Change Request” number that is created for the particular release or the deployment activity.
  • ServiceNow Success States: This indicates to the Spinnaker in which state of the “ServiceNow Change Ticket”, the Spinnaker pipeline should proceed to the next stage. e.g. Approved.
  • ServiceNow Retry States: This indicates to the Spinnaker for what and all the statues of the ServiceNow Change Ticket, the Spinnaker pipeline should wait and retry before the change ticker is moved to the ‘Success’ state.
  • ServiceNow Termination States: This indicates to the Spinnaker, in which state of the “ServiceNow Change Ticket” the Spinnaker pipeline should be ‘Terminated’.
  • ServiceNow Canceled States: This Indicates to the Spinnaker, in which state of the “ServiceNow Change Ticket” the Spinnaker pipeline should be ‘Canceled’.

Execution of the ServiceNow integrated Spinnaker CI/CD pipelines :

  • The pipelines that the user creates with this ‘CustomStage’ will need to have the “ChangeRequest number” as one of the mandatory parameters.
Configure parameters (ChangeRequest Number) for Custom Stage
  • The pipeline will take this “Change Number” as the input and check for the status of the Change ticket in the ServiceNow.
  • Once the status of the Change ticket is moved to the desired state by the ServiceNow Change ticket approver, then only this stage will be marked as the ‘Success’ and will be moved to the next deployment of the application into the respective environments.
Manual approval for the CustomStage

If the change request is moved to any of the other statuses then based on the status of the ticket, the pipeline will be canceled or terminated. These states can be configured in the Pipeline.

Configuration of different ChangeRequest status

If you want to know more about the Spinnaker integrations or request a demonstration, please book a meeting with us.

OpsMx is a leading provider of Continuous Delivery solutions that help enterprises safely deliver software at scale and without any human intervention. We help engineering teams take the risk and manual effort out of releasing innovations at the speed of modern business. For additional information, contact us

Vamsi Krishna

Vamsi Krishna is a Software Engineer at OpsMx and has over 5+ years of industrial expertise in the DevOps domain. He has previously worked in companies like IBM, Kloud9. His current assignments involve, build and release activities with the high efficient CI/CD tools on to the different environments (both on-prem and Cloud), design and build and deliver highly scalable applications while extending existing Open Source platforms. He has fair knowledge in building a microservice-based application on to the Kubernetes Clusters hosted on different cloud Environments and in integrating DevOps Applications end to end and implementing the complete Automated systems as per the requirements. He holds CKA certification. He has also developed ticketing systems using Jira Administration for the Projects. His areas of expertise include - Cloud, GCP, Kubernetes/ Docker, Jenkins, Jira,Git, High Availability.



Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.