Check sub-task status in Post-Function and stop from transition if sub-task still in Open status.

Hello,

 

I have added transition in a workflow from status "In Review" to "QA Open". This transition set with option triggers "Automatically transitions the issue when a related pull request is merged".

I noticed that Triggers will ignore Conditions and Validators.

Atlassian support suggest to create groovy script to be add in ScriptRunner in Post Function.

I am quite new in creating this groovy script. Does anyone has script example to check sub-task status in Post-Function and script example to stop from proceed transition.

2 answers

Hi Farhan,

This might be quite straight-forward in your use case. You could use a built-in script called "Fast-track transition an issue" with a condition added to it. That would limit the amount of Groovy that you need to write.

You can find a good example of it in the documentation https://scriptrunner.adaptavist.com/5.2.4/jira/builtin-scripts.html#_fast_track_transition_an_issue

This approach works by transitioning the issue back to its original state rather than "stopping" the transition (hopefully this would work for your use case).

Here is an example of some code that will retrieve the sub-tasks for an issue that you can use in the condition field. You just need to add the condition that you want to check on and return the relevant value (see built-in examples for condition field)

issue.getSubTaskObjects().each{ subtask ->
println(subtask.id)
}

 I hope this helps!

Steve

Thanks Steve,

As your suggestion, I have created 2 transition.

  1. Transition1 for the trigger which loop back to original state. At the Post Function I use the Fast-track transition and just leave the condition blank as it will assume as true then Action to Transition2. (In this transition I add condition hide transition from user)
  2. Transition2, linked to next state with condition to check sub-task status.

It works like charm :)

Glad to hear it worked :-)

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Apr 10, 2018 in Marketplace Apps

Learn about how Stefan K. built one of the *first ever* Marketplace apps

In this post you will discover more about the evolution of K15t software, some big topics they're currently focusing on in the app space, and a rare (not not funny!) photo of founders Mike Cannon-Bro...

13,073 views 11 24
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