Transitioning issue when all linked issues are "done"

Steve Beauchamp October 23, 2017

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

 

1 answer

1 vote
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2017

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" 

Steve Beauchamp October 25, 2017

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. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events