I am trying to run a conditional post-function that transitions an issue from status a to b only when all of the linked issues are set to a "Done" status category. The groovy script I have written so far is below.
This does return all of the linked issues, but it will transition even if the linked issues are not in a "done" status. Any ideas on how I can get this to work?
status = []
issue.getLinkedIssues('is blocked by').each{
status += it.getStatus().getName()
}
if (status.every{"Done"}){
return true
}
Hi Steve,
a much simpler code would be:
! issue.getLinkedIssues("is blocked by").find {
it.getStatusObject().getName() != "Done"
}
which means "cannot find a linked issue that is not in the Done status"
Thanks @David Fischer! Would this loop though all of the linked issues though?
What my coworker and I eventually came up with is:
//create a container to hold all status names
statuses = []
//fetch all linked issues to the current issue being processed.
links = issue.getOutwardIssueLinks()
// Loop though all the linked issues and when a Asset Task is found, get the linked issues off the asset task and extract all of the statuses from said linked issues.
links.each{if (it.getDestinationObject().getIssueTypeObject().getName() == "Asset Task" ){
it.getDestinationObject().getLinkedIssues('is blocked by').each{
statuses += it.getStatus().getStatusCategory().getName()}
}
}
//if all the statuses from the linked issues to the asset task are done, then this function is true
statuses.every{it == "Complete"}
This is set up on the transition from In Progress to Done on the blocking task, which transitions the "blocked" task from status a to status b.
This is working well for us, though there may still be a more efficient way to accomplish this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.