Create ServiceNow Tickets in CD Stages
This topic describes how to create Service Now tickets in CD Stages.
Harness provides the ability to create and manage ServiceNow change requests, incident tickets, change tasks, and problem type from your Pipeline step using the ServiceNow Create step.
You can add the Create ServiceNow step to a Harness CD stage or an Approval stage and do the following:
- Automatically create change requests in ServiceNow to track updates to your build, test, and production environments by adding a ServiceNow Create step in your Pipeline.
- Automatically create and assign tickets in ServiceNow to triage and resolve incidents quickly in case of Pipeline failures.
Before You Begin
- Connect to ServiceNow: you can add a Harness ServiceNow Connector before or during the Create ServiceNow step setup.
- You must install the Harness Application before using templates to create ServiceNow tickets.
- Make sure you have the following roles:
- While it's not a strict limitation, some users can forget that when you use a ServiceNow Create step, it creates a new, independent ServiceNow ticket every time it is run (as opposed to updating the same issue).
It is important to remember that you should only add ServiceNow Create to a stage if you want to create a new ServiceNow ticket on every run of the stage.
UTC Timezone Only
The ServiceNow API only allows date time and time values in the UTC timezone. Consequently, input for any datetime/time fields in Harness ServiceNow steps must be provided in UTC format irrespective of time zone settings in your ServiceNow account.
The timezone settings govern the display value of the settings not their actual value.
The display values in the Harness UI depend on ServiceNow timezone settings.
Review: ServiceNow User Roles
You can install the Harness app in your ServiceNow instance from the ServiceNow store. For more information, see Installation Guide.
To configure the Harness app in ServiceNow, you must have the following roles:
x_harne_harness_ap.integration_user_role: to access supported APIs, view Harness support details and access Templates.
itil: for end-to-end integration with Harness platform.
Step 1: Add a ServiceNow Create Step
In a Harness CD or Approval stage, in Execution, click Add Step.
Click ServiceNow Create. The ServiceNow Create settings appear.
In Name, enter a name that describes the step.
In Timeout, enter how long you want Harness to try to create the issue before failing (and initiating the stage or step Failure Strategy).
In ServiceNow Connector, create or select the ServiceNow Connector to use.
In Ticket Type, select a ServiceNow ticket type from the list.
Option: Configure Fields
Select Configure Fields to select or add ServiceNow Fields to your ServiceNow ticket. This option enables you to access multiple custom fields from your ServiceNow integration.
In Description, add the ticket description.
In Short Description, enter a description of the ticket you are creating. This will be the title of the ticket.
You can use Harness variables in the Short Description and Description fields.
Click Fields. The Add ServiceNow Fields settings appear.
Select Provide Field List to add custom fields.
Enter Key for the field.
In Value, you can write static values, or variables, to these fields.
The properties are specified as key-value pairs, the name being the field name (not the label) in ServiceNow and a valid value.
Once you are done, this is how the dialog looks:
Option: Create From Template
Select Create From Template to create a ticket using an existing template.
In Template Name, you can either enter the name of an existing template or provide an expression.
If there are many templates with the same name, the most current one is used to create tickets.Click Apply Changes.
Your ServiceNow ticket is now added to your Pipeline.
Option: Normal and Standard Change Requests
By default, Harness creates Normal Change requests, not Standard Change requests. If you want to create Standard or Emergency type ServiceNow Change request tickets, then do the following:
In Fields, select Type.
In Type, select Normal or Emergency.