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

How to Prevent Close of Epic Until All of its Issues are Closed

The OOTB template for Software projects allows an Epic to be closed even though there are Issues in the Epic that are not closed.
I want to prevent the closing of an Epic unless all of it's Issues are closed.
There is a "Sub-Task blocking condition" for the Done status has but that doesn't work for Epics.

2 answers

1 accepted

1 vote
Answer accepted

Hi Diane, 

Welcome! 

You are correct, OOTB, no such condition is included. 

But this is a popular use-case and while the problem can be resolved through business rules and training of the users, sometimes a firmer restriction is wanted. 

There are a few possibilities with apps however:

  • JMWE has this option in the UI. It's a neat tool with a low threshold for a lot of extra workflow possibilities.

Screen Shot 2018-06-08 at 16.06.24.png

  • However, if you have ScriptRunner on your instance (as every instance should), and you have someone to script it, that app makes this possible too and gives you even more functionality! 

Hope this helps! 

- Tessa

Hi Tessa,

What would the coding in Scriptrunner be if I don't have the JMWE add-on available? Could you help me with this one? Requirement: "Close epic only possible when all stories and bugs related are closed". And I would add that coding than as a post-function "Script validator"? 

Thank you for your help. 

Like Renni Verho likes this

Something like this may help : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager

// Allow logging for debug and tracking purposes
import org.apache.log4j.Level
import org.apache.log4j.Logger

// Script code for easy log identification
String scriptCode = "Check all items resolved -"

// Setup the log and leave a message to show what we're doing
Logger logger = log
//logger.setLevel( Level.ERROR )
logger.setLevel( Level.ALL )
logger.debug( "$scriptCode Triggered by $issue.key" )

passesCondition = true
if (issue.issueType.name == 'Epic')
{
IssueLinkManager issueLinkManager = ComponentAccessor.issueLinkManager
def found = issueLinkManager.getOutwardLinks(issue.id).any{
it?.destinationObject?.getResolution() == null
}
if (found){
logger.debug( "GetResolution empty found" )
passesCondition = false
} else {
logger.debug( "GetResolution no empty found" )
passesCondition = true
}
}
// Always allow all other issue types to execute this transition
else
{
logger.debug( "$scriptCode Not Epic return true" )
passesCondition = true
}

I would add here also link type verification eg. check only "Issues in Epic", but not all linked issues.

You can use the Jira Misc Workflow Extensions add-on.  This will allow you to add a validator to the workflow transition, checking the status of Stories within an Epic.

In the Software Basic project type there are no stories.  There are Epics, New Features, Improvements, Bugs, Tasks and Sub-Tasks.  No parent-child links at all except between Tasks and Sub-Tasks and sort of with Epics and all other issue types except sub-tasks.  The team I'm setting this up for does not really want stories or features, they just want tasks and sub-tasks and would like a parent of Tasks in some way. I see with the Basic Software project I can sort of create a parent of Tasks through Epics. So will the validator work between Epics and its Issues of any type?

Yes it should.  You can link Tasks to Epics in the same way you would with Stories.  Make sure the Task create/edit/view screens all have Epic Link as a field.

how to check the stories in epic.. 
I'm seeing under validator called Linked Status (JSU).. But I'm not able to find the right option for the below collumn

  • Issues which are linked as : 

@Amarendar Musham if you have JSU, use a JQL Condition (rather than a validator), it achieves a similar goal but doesn't show the transition button or allow the drag on the Kanban view.

 

You need to configure a JQL statement that checks that all child issues are done, for example:

  • JQL Expression: issue in childIssuesOf({issue.key}) and status != Done
  • Number of Issues found: Must not find issues

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

938 views 8 25
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