Pre requisites-

  1. ServiceNow Instance
  2. JIRA Instance

Steps:

  1. Get ServiceNow Instance
  2. Get JIRA instance
  3. Create a Project in JIRA
  4. Create Authentication token in JIRA
    1. Go to JIRA instance-> Go to account settings https://id.atlassian.com/manage-profile/profile-and-visibility
    2. Click on Security.
    3. Go to Create and Manage API tokens
    4. Click on Create API Token
      Note: Please note down this API Key somewhere as it is visible only at the time of creation.These are the necessary settings 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)
  7. Select the Authentication Type as Basic. A field “Basic auth profile” will be visible, specify the profile or create new.
  8. To create new Basic auth profile.
    1. Click on the search option from the field the following widow will open -> Click on New.
    2. Provide the following detailsName: Name given to the profileUsername: The email address used to create the JIRA instancePassword: This will be the API Key that we created in the JIRA -> Security. (Refer from step: 4. iv.)
  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 ServiceNowCategory:RequestSubcategory: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.
  4. In this scenario, we need to create a JIRA Story with the ServiceNow’s Incident ID, Description and Short Description.
  5. Provide the following details in the new HTTP Method:
    1. Name: Create JIRA story
    2. HTTP Method: POST
    3. Endpoint: https://yourinstancenamehere.atlassian.net/rest/api/3/issue/
    4. Authentication type: Inherit from Parent

  6. In HTTP Request add the following two headers:
    • Accept: application/json
    • Content-Type: application/json
  7. In the Content field, enter the payload that we need to send while creating the JIRA StoryFollowing 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”

    }

    ]

    }

    ]

    }

    }

    }

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

  8. Create following new Variable Substitutions
    a. Name: descriptionEscape type: No escaping Value: Blank
    b. Name: incidentNumberEscape type: No escaping Value: Blank
    c. Name: shortDescriptionEscape type: No escaping Value: Blank

  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 which will trigger the call to this Rest Message.
  11. Details of the Business Rule:Name: Create Jira StoryTable: 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);

    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.

Emergys Blog

Recent Articles

  • Service Desk Automation

    Top Candidates for Service Desk Automation

    Top Candidates for Service Desk Automation

    Automation is not new to anyone. It is the foundation [...]

    Automation is not new to anyone. It is the foundation for any enterprise digitization. However, companies [...]

  • Maximizing Customer Engagement with Salesforce

    Maximizing Customer Engagement with Salesforce

    Maximizing Customer Engagement with Salesforce

    Forget about closing deals – in today's business world, customer [...]

    Forget about closing deals – in today's business world, customer engagement is all about building bridges, [...]

  • Bridging the Gap Between Humans and Machines with Generative AI

    Bridging the Gap Between Humans and Machines with Generative AI

    Bridging the Gap Between Humans and Machines with Generative AI

    Nowadays, customers expect quick and thorough help whenever they reach [...]

    Nowadays, customers expect quick and thorough help whenever they reach out, whether it’s to order something, [...]