Incident Management

For Integration of Jira ITSM tool with iAutomate, perform the following steps:

Figure 1. Integration with Jira ITSM Tool
A screenshot of a computer Description automatically generated
  1. Create Data Source:
  2. Fetch Data
    • URL: URL>/rest/api/2/search?fields=#columns#&jql=issuetype=Incident AND status=Open AND updated >= "#start_date#" AND updated <= "#end_date#" ORDER BY updated DESC
    • Authentication Type: Basic
    • Request Method: GET
    • URL Path Parameters:
    Table 1. Sample Response Key Value Mapping
    Key Value Type Value
    #columns# Text

    key,description,summary,created,updated,

    status,assignee,resolutiondate

    #start_date# SQL UDF @@GetFromDateTimeUsingIncidentModifiedDate
    #end_date# SQL UDF @@GetToolCurrentDateTime
  3. Response Body:
    {
    "expand": "schema,names",
    "startAt": 0,
    "maxResults": 50,
    "total": 3,
    "issues": [{
    "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
    "id": "10102",
    "self": "http://<ipaddress>:<port>/rest/api/2/issue/10102",
    "key": "IT-48",
    "fields": {
    "summary": "REST ye merry gentlemen. Rest in peace",
    "resolutiondate": "2021-05-05T13:17:10.000+0530",
    "created": "2021-05-05T13:17:10.000+0530",
    "description": "Creating of an issue using project keys and issue type names using the REST API",
    "assignee": null,
    "updated": "2021-05-05T13:17:10.000+0530",
    "status": {
    "self": "http://<ipaddress>:<port>/rest/api/2/status/1",
    "description": "The issue is open and ready for the assignee to start work on it.",
    "iconUrl": "http://<ipaddress>:<port>/images/icons/statuses/open.png",
    "name": "Open",
    "id": "1",
    "statusCategory": {
    "self": "http://<ipaddress>:<port>/rest/api/2/statuscategory/2",
    "id": 2,
    "key": "new",
    "colorName": "blue-gray",
    "name": "To Do"
    }
    }
    }
    }]
    }
  4. Mandatory Parameter Mapping:
    Figure 2. Mandatory Parameter Mapping
    A screenshot of a computer Description automatically generated
  5. Optional:
    Figure 3. Optional
    A screenshot of a computer Description automatically generated
  6. Release Rule:

    For release, Jira has 3 different APIs to change the assignee, to add a comment and to add worklog. So, we are using iAutomate Custom Script API to update all 3 operations with one single API.

    Note:
    To create Custom API, go to Manage Custom Script Section.

    URL: https://url.servicenow.com/api/now/v1/table/sc_request?sysparm_fields=#Columns

    1. Authentication Type: Basic
    2. Request Method: POST
  7. Request Body:
    {
    "key": "#ticketId#",
    "URL": "http://<ipaddress>:<port>/rest/api/2/issue/",
    "assignee_name": "#assignee_name#",
    "release_comment":"Ticket_released_from_iAutomate "
    }
  8. Response Body:
    {"result":"#success#"}
    Figure 4. Response Body
    A screenshot of a computer Description automatically generated
  9. Close Rules:
    • URL: http://<ipaddress>:<port>/rest/api/2/issue/#key#/transitions
    • Authentication Type: Basic
    • Request Method: POST

    URL Path Parameters:

    Key Value Type Value
    #key# Table.Columns Col1
  10. Request Body:
    {
    "update": {
    "comment": [
    {
    "add": {
    "body": "#worknote#"
    }
    }
    ]
    },
    "transition": {
    "id": "#statuscode#"
    }
    }
  11. Response Body
    {“result" : "ok" }
  12. InProgress Rules:
  13. Request Body:
    {
    "update": {
    "comment": [
    {
    "add": {
    "body": "#worknote#"
    }
    }
    ]
    },
    "transition": {
    "id": "#statuscode#"
    }
    }
  14. Response Body:
    { "result" : "ok" }

JsResponseConverter: After successful creation of data source, follow these steps -

  1. Go to CollectIncident job under menu Configuration 🡪 Manage Jobs.
  2. Click on icon. A popup will be opened.
  3. Go to parameter tab and search for ‘JsResponseConverter’ in the end. Replace its value with below string:
    if(json.issues){for(var result=[],i=0;i<json.issues.length;i++)result.push(json.issues[i]);customJobject.dataCollectorNode.data.issues=result}

Manage Rules:

For each of the release, close, and in-progress rules are defined as follows:

  1. Release Rules:
    Parameter Value Type Value
    #assignee_name# Text Assignee_user
    #ticketId# Table.Columns Col1
  2. Close Rules:
    Parameter Value Type Value
    #worknote# Text Tickets closed from iAutomate
    #ticketId# Text 91
  3. In Progress Rules:
    Parameter Value Type Value
    #worknote# Text Ticket marked to in progress
    #ticketId# Text 31

Manage Custom Script:

To use multiple Jira APIs that are being used while releasing an incident, you need a python script that contains the calling of all required APIs.

  1. For that go to page Advance Configuration 🡪 Script🡪 Manage Custom ScriptRBA.
  2. Select Input Mode as Manual, Script Language as Python, enter the name of script in the Script Name textbox.
  3. Enter Tags (if needed) and paste the content below in the Script Text textbox.
    import json
    import requests
    import sys
    try:
    ##url = "http://<ipaddress>:<port>/rest/api/2/issue/IT-90/assignee" //update assignee
    ## Mandory
    resp = json.loads(sys.argv[2])
    url = resp["URL"] + resp["key"] + "/assignee"
    payload = json.dumps({
    "name": resp["assignee_name"]
    })
    headers = {
    'Authorization': 'Basic QXNoaXNoTWlzaHJhOkluZGlhQDEyMw==',
    'Content-Type': 'application/json'
    }
    response = requests.request("PUT", url, headers=headers, data=payload)
    print(response.text)
    import requests
    import json
    import sys
    ##url = "http://<ipadress>:<port>/rest/api/2/issue/IT-90" //add comment
    resp = json.loads(sys.argv[2])
    url = resp["URL"] + resp["key"]
    payload = json.dumps({
    "update": {
    "comment": [
    {
    "add": {
    "body": resp["release_comment"]
    }
    }
    ]
    }
    })
    response = requests.request("PUT", url, headers=headers, data=payload)
    print(response.text)
    import requests
    import json
    import sys
    ##url = "http://<ipaddress>:<port>/rest/api/2/issue/IT-90/worklog" //add worklog
    ## Mandory
    resp = json.loads(sys.argv[2])
    url = resp["URL"] + resp["key"]+"/worklog"
    payload = json.dumps({
    "comment": resp["release_comment"],
    "timeSpentSeconds": 6000
    })
    response = requests.request("POST", url, headers=headers, data=payload)
    print(response.text)
    except Exception as e:
    message = {"Error": "Error in running Script, Error=>" + str(e)}
    message = json.dumps(message)
    code = 400
    print(str(message))