Jira Cloud + ScriptRunner
When working with Jira, we wanted the fixVersion
of any ticket to be automatically set based on the fixVersion of it’s associated epic. To do this, create a script listener with ScriptRunner that listens to both the Issue Created
and Issue Updated
events with the following contents:
def epicKey = get('/rest/api/2/issue/' + issue.key).asObject(Map).body['fields']['customfield_10003']
if (!epicKey) {
return false;
}
def epicFixVersions = get('/rest/api/2/issue/' + epicKey).asObject(Map).body['fields']['fixVersions']
if (epicFixVersions.size() == 0) {
return false;
}
def epicName = epicFixVersions[0]['name']
def result = put('/rest/api/2/issue/' + issue.key)
.header('Content-Type', 'application/json')
.body([
fields:[
fixVersions: [[name: epicName]]
]
]).asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}