Integration with JIRA

BigFix Runbook AI integrates with JIRA for Incident Management (IM) by creating and managing the required IM data sources. This integration also helps user monitor sub-task management throught JIRA.

Incident Management

For Integration of Jira ITSM tool with BigFix Runbook AI, perform the following steps:

Figure 1. Figure 260  Integration with Jira ITSM Tool

Create Data Source:

  • Fetch Data Configuration:
  • 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:
Key Value Type Value
#columns# Text

key,description,summary,created,updated,

status,assignee,resolutiondate

#start_date# SQL UDF @@GetFromDateTimeUsingIncidentModifiedDate
#end_date# SQL UDF @@GetToolCurrentDateTime
  • Response Body:

{

"expand": "schema,names",

"startAt": 0,

"maxResults": 50,

"total": 3,

"issues": [{

"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",

"id": "10102",

"self": "http://10.1.152.20:8080/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://10.1.152.20:8080/rest/api/2/status/1",

"description": "The issue is open and ready for the assignee to start work on it.",

"iconUrl": "http://10.1.152.20:8080/images/icons/statuses/open.png",

"name": "Open",

"id": "1",

"statusCategory": {

"self": "http://10.1.152.20:8080/rest/api/2/statuscategory/2",

"id": 2,

"key": "new",

"colorName": "blue-gray",

"name": "To Do"

}

}

}

}]

}

  • Mandatory Parameter Mapping:
Figure 2. Figure 261  Mandatory Parameter Mapping
Graphical user interface Description automatically generated
  • Optional:
Figure 3. Figure 262  Optional
Graphical user interface, application Description automatically generated

Release Rule Configuration:

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

To create Custom API go to Manage Custom Script Section.

{

"key": "#ticketId#",

"URL": "http://10.1.152.20:8080/rest/api/2/issue/",

"assignee_name": "#assignee_name#",

"release_comment":"Ticket_released_from_BigFix Runbook AI"

}

  • Response Body:

{"result":"#success#"}

Figure 4. Figure 263  Response Body
Graphical user interface, application Description automatically generated

Close Rules Configuration:

Key Value Type Value
#key# Table.Columns Col1
  • Request Body:

{

"update": {

"comment": [

{

"add": {

"body": "#worknote#"

}

}

]

},

"transition": {

"id": "#statuscode#"

}

}

  • Response Body:

{ "result" : "ok" }

InProgress Rules Configuration:

Key Value Type Value
#key# Table.Columns Col1
  • Request Body:

{

"update": {

"comment": [

{

"add": {

"body": "#worknote#"

}

}

]

},

"transition": {

"id": "#statuscode#"

}

}

  • Response Body:

{ "result" : "ok" }

JsResponseConverter: After successful creation of data source,

  • Go to CollectIncident job under menu Environment  Manage Jobs.
  • Click on icon. A popup will be opened.
  • 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:

Release Rules

Parameter Value Type Value
#assignee_name# Text Assignee_user
#ticketId# Table.Columns Col1

Close Rules:

Parameter Value Type Value
#worknote# Text Ticket closed from BigFix Runbook AI
#ticketId# Text 91

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.

  • For that go to page Environment  Manage Custom Script  Create Script.
  • Select Input Mode as Manual, Script Language as Python, enter the name of script in the Script Name textbox.
  • Enter Tags (if needed) and paste below content in the Script Text textbox.

import json

import requests

import sys

try:

##url = "http://10.1.152.20:8080/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://10.1.152.20:8080/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://10.1.152.20:8080/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))

Sub-Task Management

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

Figure 5. Figure 264 - Integration of Jira IITSM Sub-Task

Create Data Source:

  • Fetch Data Configuration:
  • 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
  • Authentication Type: Basic
  • 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
  • Response Body:

{

"expand": "schema,names",

"startAt": 0,

"maxResults": 50,

"total": 3,

"issues": [{

"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",

"id": "10102",

"self": "http://10.1.152.20:8080/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://10.1.152.20:8080/rest/api/2/status/1",

"description": "The issue is open and ready for the assignee to start work on it.",

"iconUrl": "http://10.1.152.20:8080/images/icons/statuses/open.png",

"name": "Open",

"id": "1",

"statusCategory": {

"self": "http://10.1.152.20:8080/rest/api/2/statuscategory/2",

"id": 2,

"key": "new",

"colorName": "blue-gray",

"name": "To Do"

}

}

}

}]

}

  • Mandatory Parameter Mapping:
Figure 6. Figure 265  Mandatory Parameter Mapping
Graphical user interface Description automatically generated
  • Optional:
Figure 7. Figure 266  Optional

Release Rule Configuration:

For release, since Jira has 3 different APIs to change the assignee, to add a comment and to add worklog. So, we are using BigFix Runbook AI’s Custom Script API to update all 3 operations with a single API.

{

"key": "#ticketId#",

"URL": "http://10.1.152.20:8080/rest/api/2/issue/",

"assignee_name": "#assignee_name#",

"release_comment":"Ticket released from BigFix Runbook AI"

}

Response Body:

{"result":"#success#"}

Figure 8. Figure 267  Response Body
Graphical user interface, application Description automatically generated

Close Rules Configuration:

Key Value Type Value
#key# Table.Columns Col1
  • Request Body:

{

"update": {

"comment": [

{

"add": {

"body": "#worknote#"

}

}

]

},

"transition": {

"id": "#statuscode#"

}

}

Response Body: { "result" : "ok" }

InProgress Rules Configuration:

Key Value Type Value
#key# Table.Columns Col1
  • Request Body:

{

"update": {

"comment": [

{

"add": {

"body": "#worknote#"

}

}

]

},

"transition": {

"id": "#statuscode#"

}

}

  • Response Body:

{ "result" : "ok" }

JsResponseConverter: After successful creation of data source,

  • Go to CollectIncident job under menu EnvironmentManage Jobs.
  • Click on icon. A popup will be opened.
  • 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 inprogress, rules will be defined as follows:

Release Rules:

Parameter Value Type Value
#assignee_name# Text <Assignee_user>
#ticketId# Table.Columns Col1

Close Rules:

Parameter Value Type Value
#worknote# Text Ticket resolved from BigFix Runbook AI
#statuscode# Text 61

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.

  • For that go to page EnvironmentManage Custom Script Create Script.
  • Select Manual as Input Mode, Python as Script Language, enter the name of script in the Script Name textbox.
  • Enter tags if needed and paste below content as it is in Script Text textbox.

import json

import requests

import sys

try:

##url = "http://10.1.152.20:8080/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://10.1.152.20:8080/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://10.1.152.20:8080/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))