Sub-Task Management

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

Figure 1. Integration of Jira ITSM Sub-Task
A screenshot of a phone Description automatically generated
  1. Create Data Source
  2. Fetch Data Configuration
    1. Sample URL: http://<JIRA_URL>/rest/api/2/search?fields=#columns#&jql=issuetype="Sub-task" AND status=Open AND updated >= "#start_date#" AND updated <= "#end_date#" ORDER BY updated
    2. Authentication Type: Basic
    3. Request Method: GET

      URL Path Parameters:

      Key Value Type Value
      #columns# Text key,description,summary,created,updated,status,assignee,resolutiondate, issuetype
      #start_date# SQL UDF @@GetFromDateTimeUsingTaskModifiedDate_Jira
      #end_date# SQL UDF @@GetToolCurrentDateTime_Jira
  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
  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 a single API.

    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 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:

    URL Path Parameters:

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

JsResponseConverter: After successful creation of data source,

  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.
  4. Replace its value with the 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 inprogress, rules will be defined as follows:

Release Rules:

Parameter Value Type Value
#assignee_name# Text <Assignee_user>
#ticketId# Table.Columns Col1
  1. Close Rules:
    Parameter Value Type Value
    #worknote# Text Ticket resolved from iAutomate
    #statuscode# Text 61
  2. In Progress Rules:
    Parameter Value Type Value
    #worknote# Text Ticket marked to in progress
    #statuscode# Text 11

Manage Custom Script:

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

  1. For that go to page Advance Configuration 🡪 Script 🡪 Manage Custom Script 🡪 Create Script.
  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 textb
    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://<ipaddress>:<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))