Transitioning issue when all linked issues are "done" Edited

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

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 [Innovalog]! 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
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,439 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you