The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Shweta Kadam1
Tera Expert

 

Prerequisites-

  1. ServiceNow Instance
  2. JIRA Instance

Steps:

 

  1. Get ServiceNow Instance
  2. Get JIRA instance
  3. Create a Project in JIRA
  4. Create an Authentication token in JIRA

 

i.                     Go to JIRA instance-> Go to account settings https://id.atlassian.com/manage-profile/profile-and-visibility

 

ii.                   Click on Security.

find_real_file.png

 

iii.                     Go to Create and Manage API tokens

find_real_file.png

  

iv.                     Click on Create API Token

find_real_file.png

 

 Note: Please note down this API Key somewhere as it is visible only at the time of creation.

 

These are the necessary setting to be done in JIRA in order to begin with Integration.

5. Now in the ServiceNow instance, we need to create a Rest Message under System Web Services-> Outbound -> REST Message.

6. Click on New. This will open a new form to enter the details of Rest Message.

 

 Name: provide the name for the Rest Message.

 Description: provide the details as in what all methods will be created from this Rest Message.

 Endpoint: endpoint comprises of the instance name with the Rest API version the 3rd party application is providing. 

 Authentication Type: provide the authentication type used by the API. (Basic/OAuth 2.0)

find_real_file.png

7. Select the Authentication Type as Basic. A field “Basic auth profile” will be visible, specify the profile or create new.

       8. To create a new Basic auth profile.

        i.  Click on the search option from the field the following window will open -> Click on New.

find_real_file.png

ii.          Provide the following details

Name: Name given to the profile

Username: The email address used to create the JIRA instance

          Password: This will be the API Key that we created in the JIRA -> Security. (Refer from step: 4. iv.)

find_real_file.png

        9. Click on Default Get.,

-       Provide the endpoint and HTTP Request in headers

-       Accept: application/json, Content-Type: application/json

-       Click on Test

 

Integration Usecase

If any new Incident for enhancement request is raised in ServiceNow, create a JIRA User Story and store the JIRA ID on the Incident for that particular enhancement. 

1.Create the category and subcategory in ServiceNow

Category:         Request

Subcategory:    Enhancement 

        2. Go to System Web Services -> Outbound -> Rest Message.

 3. Open the Rest Message that we created. In this Rest Message, we will add a new HTTP method in order to achieve the integration.

      find_real_file.png

        4. In this scenario, we need to create a JIRA Story with ServiceNow’s Incident ID, Description, and Short Description. 

        5.     Provide the following details in the new HTTP Method:

a.  Name: Create JIRA story

b.  HTTP Method: POST

c.  Endpoint: https://yourinstancenamehere.atlassian.net/rest/api/3/issue/

d.  Authentication type: Inherit from Parent

      find_real_file.png

       6.       In HTTP Request add the following two headers:

a.  Accept: application/json

b.  Content-Type: application/json

       7.     In the Content field, enter the payload that we need to send while creating the JIRA Story

Following is the request body I have used:

{

    "fields": {

       "project":

       {

          "key": "SER"

       },

       "summary": "${shortDescription}",

       "issuetype": {

          "name": "Story"

       },

       "customfield_10037": "${incidentNumber}",

        "description": {

      "type": "doc",

      "version": 1,

      "content": [

        {

          "type": "paragraph",

          "content": [

            {

              "text": "${description}",

              "type": "text"

            }

          ]

        }

      ]

    }

   } 

}

find_real_file.png

 

Note: "${shortDescription}”, "${incidentNumber}”, "${description}” are the variables created to pass the data dynamically.

8.       Create following new Variable Substitutions

a.       Name: description                Escape type: No escaping          Value: Blank

b.       Name: incidentNumber         Escape type: No escaping          Value: Blank

c.       Name: shortDescription        Escape type: No escaping          Value: Blank

find_real_file.png

9.     You can test, this method by providing some test data in the variables and Click on “Test” from the Related Links.

10.  We now need to create a Business rule on Incident Table that will trigger the call to this Rest Message.

11.  Details of the Business Rule:

Name: Create Jira Story

Table: Incident

When to Run:

          When: after Insert, Update

          Filter Conditions:

          Category is Request

          Subcategory is Enhancement

Advanced:

          Script:

          (function executeRule(current, previous /*null when async*/ ) {

     // Add your code here

     try {

        var createJiraStory = new sn_ws.RESTMessageV2('SNOW JIRA Integration', 'Create JIRA Story');

        createJiraStory.setStringParameterNoEscape('description', current.description);

        createJiraStory.setStringParameterNoEscape('shortDescription', current.short_description);

        createJiraStory.setStringParameterNoEscape('incidentNumber', current.number);

         var response = createJiraStory.execute();

        var responseBody = response.getBody();

        var httpStatus = response.getStatusCode();

         var getJiraUserStoryID = JSON.parse(responseBody);

        var jiraUserStoryID = getJiraUserStoryID.key;

         current.setValue('u_jira_id', jiraUserStoryID);

       current.update();

     } catch (ex) {

        var message = ex.message;

    }

 })(current, previous);

find_real_file.png

find_real_file.png

find_real_file.png

Note: The code to mention in this business rule can also be obtained from the Rest message

Go to the desired Method you have created. For example, Create Jira Story, in the Related Links you will find the link “Preview Script Usage”, this link gives the sample code you can use in the BR.

12.    A field called, “JIRA ID” is created on ServiceNow Incident form, which will be updated after the Story is created in JIRA. The code in the business rules updates the JIRA ID from the response received.

 

 

 

 

 

 

Comments
Aks0122
Tera Contributor

Hi ,

You said bidirectional (Servicenow to Jira)so you will also have data come in from the Jira end let's say comment, work node that is coming from Jira. How is update that on the incident?

jberghall
Tera Explorer

Bidirectional is pretty complex since Jira and SNOW work on a totally different logic. That's why we have many customers whose first integration is ServiceNow-Jira because they need bidirectional real-time integration, but don't spend time to develop needed logic or amend their processes. Integrating SNOW to Jira shouldn't take longer than 15 mins as a self-service.

Take a look at how to do it here (Youtube)


(and start your free trial here)



jberghall
Tera Explorer

For some reason, my comment was duplicated. 

Chandra2
Tera Contributor

Kindly share Jira to ServiceNow steps?

JuhaB
Tera Explorer
Version history
Last update:
‎06-27-2021 10:31 AM
Updated by: