Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Amplify Integration Builder Jira Cloud Connector Event Webhooks Assets
{
"id": 62313,
"name": "Jira Webhook Test Full",
"debugLoggingExpires": "2021-09-03T01:19:24Z",
"userId": 21107,
"accountId": 18281,
"createdDate": "2021-09-13T14:50:39Z",
"steps": [{
"id": 568885,
"onSuccess": ["setGlobals"],
"onFailure": [],
"name": "getFields",
"type": "elementRequest",
"properties": {
"api": "/fields",
"method": "GET",
"elementInstanceId": "${config.jira}"
}
}, {
"id": 568886,
"onSuccess": ["processEpic"],
"onFailure": [],
"description": "Check to see that issue is of type Epic",
"name": "isEpic",
"type": "filter",
"properties": {
"body": "done(trigger.body.message.raw.issue.fields.issuetype.name === 'Epic');"
}
}, {
"id": 568887,
"onSuccess": ["isWatchedProject"],
"onFailure": [],
"description": "Make sure the event relates to an issue/epic and not Project, ...",
"name": "isIssue",
"type": "filter",
"properties": {
"body": "done(trigger.event.objectType === 'issue');"
}
}, {
"id": 568888,
"onSuccess": ["getFields"],
"onFailure": [],
"description": "Check to see if the issue relates to a linked project",
"name": "isWatchedProject",
"type": "filter",
"properties": {
"body": "let projectKey = trigger.body.message.raw.issue.key.split('-')[0];\n\n\ndone(config.jiraProjectKeys.includes(projectKey));"
}
}, {
"id": 568889,
"onSuccess": [],
"onFailure": [],
"name": "processEpic",
"type": "script",
"properties": {
"body": "let epicId;\n\nif(trigger.body.message.raw.issue.fields.issuetype.name === 'Epic') {\n epicId = trigger.body.message.raw.issue.key;\n} else {\n epicId = trigger.body.message.raw.issue.fields[config.globals.epicLinkCustomFieldName]\n}\n\nconsole.log('Process Epic: '+epicId);\n\ndone({});"
}
}, {
"id": 568890,
"onSuccess": ["processEpic"],
"onFailure": [],
"name": "setGlobals",
"type": "script",
"properties": {
"body": "function findObjectByKey(array, key, value){\n for (var i = 0; i < array.length; i++) {\n if (array[i][key] === value) {\n return array[i];\n }\n }\n return null;\n}\n\nlet fields = steps.getFields.response.body;\n\nlet epicLinkCustomField = findObjectByKey(fields, 'name', 'Epic Link');\n\nlet epicLinkCustomFieldName = epicLinkCustomField.key\n\n\nlet globals = {\n epicLinkCustomFieldName\n}\n\nconfig.globals = globals;\n\ndone({});"
}
}],
"triggers": [{
"id": 51558,
"onSuccess": ["isIssue"],
"onFailure": [],
"type": "event",
"async": true,
"active": true,
"name": "trigger",
"properties": {
"elementInstanceId": "${config.jira}"
}
}, {
"id": 51557,
"onSuccess": ["isIssue"],
"onFailure": [],
"type": "manual",
"async": true,
"active": false,
"name": "trigger",
"properties": {}
}],
"engine": "v3",
"active": true,
"debugLoggingEnabled": false,
"singleThreaded": false,
"configuration": [{
"id": 99748,
"key": "jira",
"name": "jira",
"type": "elementInstance",
"required": true
}, {
"id": 99749,
"key": "jiraProjectKeys",
"name": "jiraProjectKeys",
"type": "value",
"description": "Array of watched project keys",
"required": true
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment