I'm using Scriptrunner for Jira Cloud. I've found the post function to transition a parent when a subtask transitions, but I would like the entire hierarchy to transition as well - Sub-task, Story and Epic. I'm not finding how to get the parent of any issue type except Sub-task.
def transitionID = '21' // My global In Progress transition ID
def parentKey = 0
if (((Map) issue.fields.issuetype)?.name == 'Sub-task') {
parentKey = issue.fields.parent.key
} else {
What goes here?
}
// The rest call to transition the issue
def result = post("/rest/api/2/issue/${parentKey}/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: transitionID]])
.asObject(Map)
// Check if the issue was transitioned correctly
// Log out the issues updated or which failed to update
if (result.status == 204) {
logger.info("The ${parentKey} issue was also transitioned by the post function.")
} else {
logger.warn("The post function failed to transition the ${parentKey}issue. ${result.status}: ${result.body}")
}
Obviously a WIP but help with this part would be appreciated