Automation for Jira - How to automatically close an Initiative issue once all its Epics are closed
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The purpose of this article is to provide a way to configure an automation rule that will automatically close an Initiative (or any other type of parent issue), once all its child issues (such as Epics) are closed.
For this solution:
- We will assume that the Initiative issue and its child Epic issues are considered as closed when they are in the Status DONE
- We will also assume that the parent/child relationship is configured as below in the Hierarchy Levels page that comes with the application Advanced Roadmaps For Jira:
- The hierarchy levels are configured so that the Initiative issue type is a parent of the Epic issue type:
- With such hierarchy level configuration, we will have the Parent/Child relationship described in the examples below:
- The issue SCRUM-29 is a parent issue of the 2 Epics SCRUM-30 and SCRUM-31 (as shown in the Child Issues panel):
- The issue SCRUM-30 (and SCRUM-31) child issues of the issue SCRUM-29 (as indicated in the Parent Link field):
- The issue SCRUM-29 is a parent issue of the 2 Epics SCRUM-30 and SCRUM-31 (as shown in the Child Issues panel):
- The hierarchy levels are configured so that the Initiative issue type is a parent of the Epic issue type:
If you are using different parent/child relationship in the Hierarchy Levels configuration with different issue types, it will be necessary to slightly adjust the solution provided in this KB article, based on your own configuration. Additionally, if you are using a different status than DONE to indicate that an issue is closed, you will need to change the automation rule slightly to reflect it.
Environment
- Jira Software Server/Data Center on any version from 8.0.0
- Advanced Roadmaps For Jira on any version
- Automation For Jira on any version from 7.4.0
Solution
Preliminary steps
Before configuring the automation rule, you need to first identify the ID of the Parent Link custom field, since this ID will be different depending on the Jira environment:
- Go to ⚙ > Issues > Custom Fields
- Search for the Parent Link custom field, and click on ... > View
- Get the ID from the URL: it is custom field ID that is needed to configure the automation rule
Rule Configuration
The automation rule will be configured like this:
New Trigger: Issue transitioned
- From status: leave blank
- To status: Done
Make sure to change the status to the one used in the workflow when an issue is closed (for example: Closed, Resolved, etc...)
New Condition: Issue fields condition
- Field: Issue type
- Condition: Equal
- Value: Epic
Branch Rule / related issues
Type of related issues: JQL
key in parentIssuesOf("{{triggerIssue.key}}")
- Untick the option Only include issues that have changed since the last time this rule executed
- Rule restricted to projects: <Your project name here>
In the Branch:
New Condition: Issue Field Condition
- Status: Status
- Condition: Does not equal
- Value: Done
Make sure to change the status to the one used in the workflow when an issue is closed (for example: Closed, Resolved, etc...)
- Rule restricted to projects: <Your project name here>
New Related issues condition
- Related Issues: JQL Issues
Related issues JQL: (Replace XXXXX with the Custom Field ID of the Parent Link field, based on the preliminary steps)
"Parent Link" = {{triggerIssue.customfield_XXXXX}}
Condition: "All match specified JQL"
Matching JQL: (change the status to the one indicating that an issue is closed)
status = Done
New Action: Transition issue
- Transition the issue by: Selecting the destination status
- Destination status: Done
Make sure to change the status to the one used in the workflow when an Epic/Initiative is closed (for example: Closed, Resolved, etc...)
The automation rule will look like this: