Adding ServiceNow Approval Stages
You can use ServiceNow tickets to approve or reject a Pipeline or stage at any point in its execution.
During deployment, a ServiceNow ticket's fields are evaluated according to the criteria you define, and its approval/rejection determines if the Pipeline or stage may proceed.
Approvals can be added as stages or in-between stage steps to prevent stage execution from proceeding without approval.
For example, in a Kubernetes Blue Green Deployment, you might want to add an approval step between the Stage Deployment step, where the new app version is deployed to the staging environment, and the Swap Primary with Stage step, where production traffic is routed to the pods for the new version.
In this topic:
- Before You Begin
- Review: ServiceNow Approval Stages vs Steps
- Step: Add an Approval Step
- Step 2: Set Approval Criteria
- Option: Set Rejection Criteria
- Option: Advanced Settings
- Step 3: Apply and Test
- Review: Issue Expressions
- See Also
Before You Begin
Review: ServiceNow Approval Stages vs Steps
You can use ServiceNow Approvals in two ways:
- ServiceNow Approval step: you can add a ServiceNow Approval step to any Pipeline or Approval stage.
- ServiceNow Approval stage: the ServiceNow Approval stage.
Step: Add an Approval Step
In your Pipeline, click Add Stage.
Click Approval. The Stage settings appear.
In Name, enter a name for your Stage and select ServiceNow as approval type. Click Setup Stage. The ServiceNow Approval settings appear.
In Timeout, enter how long you want Harness to try to complete the step before failing (and initiating the stage or step Failure Strategy).
You can use
w for week,
d for day,
h for hour,
m for minutes,
s for seconds and
ms for milliseconds. For example, 1d for one day.
ServiceNow communication can take a few minutes. Do not use a brief timeout.
In ServiceNow Connector create or select the ServiceNow Connector you want to use.
Select the ServiceNow Ticket Type.
Enter the Issue Number.
Step 2: Set Approval Criteria
The Approval Criteria in the step determines if the Pipeline or stage is approved or rejected.
You can specify criteria using Conditions and/or JEXL Expression. If you use them in combination, they both must evaluate to
True for the step to be successful.
In Conditions, you can use the ServiceNow ticket related fields to define approval criteria.
In JEXL Expression, you can use JEXL expressions. You can use a JEXL expression if the field is set to Fixed value or Expression.
Option: Set Rejection Criteria
In Optional Configuration, in Rejection Criteria, you can define criteria for rejecting the approval.
If you add rejection criteria it is used in addition to the settings in Approval Criteria.
Option: Advanced Settings
In Advanced, you can use the following options:
Step 3: Apply and Test
Click Apply Changes. The ServiceNow approval step is added to the stage.
Run the Pipeline.
When the ServiceNow Approval step is reached, you can see its approval and rejection criteria:
Review: Issue Expressions
You can use
<+ticket> to refer to the value in the JEXL Expression setting.
<+ticket.state.displayValue> == "New" in the Approval Criteria, JEXL Expression checks to see if the status of the ticket is New.
state is a ticket field. You can use any ticket field.