Select Page
by

Vardhan NS

|
last updated on May 31, 2023
Share

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 https://developer.servicenow.com/dev.do
    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.
  • 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
url: https://dev83627.service-now.com/api/sn_chg_rest/v1/change/normal?sysparm_query=number=${parameterValues['issue']}
customHeaders:
   Authorization: Basic
   Content-Type: application/json
failPipeline:true
progressJsonPath: "result[0].state.display_value"
payload: ""
retryStatusCodes: -200
statusJsonPath: "result[0].state.display_value”
statusUrlResolution:"getMethod"
successStatuses: ${parameterValues['success']}
retryStatuses: ${parameterValue['retry']}
terminalStatuses:${parameterValues['terminate']}
canceledStatuses: ${parameterValues['cancel']}
waitBeforeMonitor:"1"
waitForCompletion: true
				
			

parameters:
– 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.
  • 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.

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.

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

Vardhan NS

Vardhan is a technologist and a marketing professional, currently working as a Sr. PMM at OpsMx. His strength lies in understanding complex technologies, and explaining them in un-complicated ways. Vardhan is a passionate Product Marketer with a keen focus on Content, helping brands Position themselves uniquely with clear messaging and competitive differentiation. Outside of work, he is an athlete that is passionate about Football, Swimming and Surfing.

Link

0 Comments

Submit a Comment

Your email address will not be published.

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

You May Like

Spinnaker 1.16 – What’s New

September 9, 2019
Share

Spinnaker 1.18 – What’s New

March 8, 2020
Share