Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Auto transition epic if all linked issues are closed (Script Runner for JIRA)

Trying to set up a script listener with Script Runner for JIRA.

Have no experience with Groovy scripts and examples provided (on the plugin's page itself or wiki page here) do not apply.

What we need is a condition script that will (additionaly):

a) filter for issue type "epic" (introduced by JIRA Agile plugin)

b) filter for specific status (Development)

c) filter for (outward) issue link type "is Epic of" and get list of linked issues

d) filter for specific statuses (To Verify or Closed) of all linked issues found in c) above

Our intention is for this script listener to automatically transition all epics in Development that have all linked issues (using the Epic link type) Closed or To Verify to the next status in our custom workflow. The action (transition) is obvious to set, what we need help with is the condition that checks for all 4 things above.

Condition a) is superceded by c) - since only epics can have the outward "Epic-Story Link" link type but I still want it there in case we need to apply this to a different scenario with different issue types.

Any help or idea to the right direction is appreciated.


5 answers

Hi Daniel,

Below is a gist that has a few different examples using Script Runner:

1) Automatically transition an "Initiative" to "In Progress" if an Epic moves "In Progress". This can be useful if you have a hierarchy via links between Initiatives and Epics. Its coded in such a way that it doesn't matter what type of link is used. Place this on the "In Progress" status as a post-workflow action of an Epic.

2) Automatically transition an "Initiative" to "Closed" if an Epic moves to "Closed" and all other Epics are also in the "Closed" state. This is useful if you want to keep accurate cycle times of your hierarchy. Place this on the closed status as a post-workflow action  of the Epic.

3)Automatically transition an Epic to "Closed" if a Story moves to "Closed" and all other Stories/issues are in the "Closed" state. This should help you automate the closing of Epics based on the issues underneath. Place this on the closed status as a post-workflow action of the Story.

4) Not included in the script, but Automatically transition an Epic to "In Progress" if a Story moves in "In Progress". I use the JIRA misc workflows "transition linked issue" function and specify the transition id of the epic and "has Epic" issue type (since its a 1 to 1 mapping). I place this in the post-workflow of a Story. 

You can place this code inside of a custom post-script plugin on the Closed status of their respective (Note there are a few things hardcoded like the transition, doesn't validate the transition, issueLinkTypes. I would try and clean up a few of those.) I would also test this using the Script Console before putting it in the post-workflow function. I also place all of these after the re-index step in the post-workflow function. They are all done using the Post-groovy script -> Custom groovy script.


Thanks to @Jamie Echlin (Adaptavist) for starting off the gist and writing an awesome script runner plugin!

Hi Dorian Kersch,

As you mentioned , is there any updated code for this ? OR any link to see latest code .

Please could you provide it.


The gist I linked in my answer has all of the code for those steps. Unfortunately I haven't tested if it is compatible with Jira 7. I haven't had time to convert it by following but it shouldn't be hard. If you do convert it feel free to append it to the gist or comment back if it works.

Hi Dorian,

Thanks for reply .

I was trying "Auto-Close Epics if all the stories are closed." code.

But it's giving Type checking error : "closedStory" undeclared error in JIRA 7.1.8 .

And in below code 

if ( == "closed")

Giving worning as shown

<span class="deprecationComment"> since 7.0

use <a href="com/atlassian/jira/issue/Issue.html#getStatus--">


Please help me how to fix it.


Hi Tukaram,


Currently not by a computer but looking at their documentation change to story.getStatus.


But getStatus returns a status so you may want to do story.getStatus.getSimpleStatus which returns a simple status. Within that simple status you have the ability to get the name by calling getName(). 


So maybe try changing it to story.getStatus.getSimpleStatus.getName


You may run into other issues as there are more deprecated methods. I recommend looking at an IDE or the documentation to help determine how to convert it. The link I provided about converting to Jira7 should help you convert other parts. If you do convert it please post it back so others can get the benefit.




Thanks so much for your help and support.

In below code , you used hard code value 31 as parameter value  and  isEpicOfLinkType = 10300

Are these remain same ? if not please let me know how to find these values on my jira environment .


def updateEpic = {Issue epic ->
if (isEpicInProgress) {
def parameters = issueService.newIssueInputParameters()
def result = issueService.validateTransition(currentUser,, 31, parameters)
issueService.transition(currentUser, result)

issueLinkManager.getInwardLinks( { link ->
def linkTypeId = link.getLinkTypeId()
def isEpicOfLinkType = 10300
if (isEpicOfLinkType == linkTypeId) {
def epic = link.sourceObject
if (isEpicInProgress(epic)) {
if (isEpicClosable(epic)) {

Both those values are hardcoded, but may be the same. The below again is based on memory as I don't have a computer with a Jira instance in front of me.

To find the "31" open up the workflow to text view of your epic and look at the transition state to "Closed" or "Done". It will be next to the transition name (I'm making assumptions about how you configured epics). You will probably want to make sure it's global able to transition to that state or you will have to add more checks. 

The 10300 is the link type. If you go to your link type page in admin panel and hover over the link types it should return their values in the url. Epics have a unique one that may not be visible from that page. It can be found within the database or if you go to a workflow post function and select "transition linked issues" it should show the full drop-down. You can inspect element and find the right value associated to it. Hopefully that helps.

Hi Dorian,

As you mentioned above "story.getStatus().getSimpleStatus().getName()=="Closed"  working

But  "epic .getStatus().getSimpleStatus().getName()="Closed" epic one not working .

This was discussed during our roll out of JIRA Agile. If you have a proper solution I would appreciate it, if you can share this. :)

Is there any update on this? 

Can this be implemented using rules on workflow transitions/status' as opposed to script runner?

0 votes
andreas Community Leader May 14, 2017

Hi Daniel (and everyone else),

I'm one of the founders of Code Barrel, and we make Automation for JIRA.  

With Automation you can achieve this fairly easily. Here's an example Automation rule:



So what this does is:

  • Anytime an issue is transitioned
  • We check that the issue is a Story and was moved to 'Done'
  • Then we branch off for the Epic of that story
    • For this Epic we check that *all* its stories are now done
    • Then we transition the Epic to Done.

Hope this helps!



Hi Andreas,


I've tried both your version and my modified version below and unfortuantley it's not working. What's weird is that I have 2 tasks linked to the Epic. When I transition both from To Do to Done, nothing happens. But then when I transition 1 (either) of the tasks back to "To Do" from "Done" it updates the status of the Epic from To Do to Done.

Of course, it should be updating the status when the both tasks linked to the epic transition to Done.


2017-08-30 at 6.57 PM.png

I had this same need and set it up as Andreas did above and it worked. MAKE SURE your JQL where type = story (includes all ticket types you want to transition it on (not just story)).



Type in ("story","upgrade/ deploy","New Client Setup")


hope that helps.

With Automation you can achieve this. Here's an example of my Automation rule:

This rule does require the resolution to be set, so this might be useful to place this on a post-function in all related workflows. IN the Advanced part I specified the field Epic Status

Screen Shot 2020-07-14 at 15.37.31.png

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

290 views 3 20
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you