I'm a newbie to script runner cloud version, while executing this code it is not working as expected.
I request Script runner team to look into this issue
def issueKey = "HDWSEC-8"
// Specify the name of the version to extract from the issue
def closedStatus = 'Done'
// Specify the transition to execute on the issue
// NOTE - The transition ID must represent a valid transition for the workflow that the issue uses.
def transitionID = '3'
// Specify a boolean to flag if all issue links are resolved
boolean allIssueLinksResolved;
// Get the issue object
def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
// Find the linked issues
def linkedIssues = result.body.fields.issuelinks
// if all issue links have the Done status set the flag to true
if(linkedIssues.findAll{closedStatus.contains(it.outwardIssue.fields.status.name)}){
allIssueLinksResolved = true
}
// If any of the linked issues do not have the done status set the flag to false
if (linkedIssues.findAll{!closedStatus.contains(it.outwardIssue.fields.status.name)}){
allIssueLinksResolved = false
}
// If all issue links are resolved transition the issue
if(allIssueLinksResolved == true){
// The rest call to transition the issue
def transitionIssue = post("/rest/api/2/issue/${issueKey}/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: transitionID]])
.asObject(Map)
return "All issue links are to closed issues and the issue has been transitioned."
// If the issue contains unresolved linked issues return a message and do not transition the issue
}else if (allIssueLinksResolved == false){
return "The issue contain issue links which are not closed"
}