Automation For Jira - How to write a rule to close a parent issue after all sub-tasks have been closed
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
When a parent issue (for example Task/Bug/Story type issue...) has sub-tasks underneath it, we might want to automatically close it once all the sub-tasks have been closed.
The purpose of this article is to provide a way to configure an automation rule that will automatically close the parent issue, once the last sub-task was closed.
Environment
- Jira Service Management (JSM) Server / Data Center 4.0.0 and any higher version
- Automation for Jira 7.4.0 and any higher version
Solution
Automation rule configuration
- Add an Issue Transitioned trigger with the parameters below:
- From Status: leave empty
- To Status: choose the workflow status that issues enter when they are closed/done. For example: the status DONE
- Add an Issue Field Condition with the parameters below:
- Field: Issue Type
- Condition: Equals
- Value: Sub-task
- Add a Branch Rule with the parameter below:
- Type of related Issues: Parent
- Inside the Branch Rule, add the 2 components below:
- Add a Related Issues Condition with the parameters below:
- Related Issues: Sub-tasks
- Condition: "All match specified JQL"
- Matching JQL: "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...)
- Add a Transition Issue action with the parameters below:
- 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 issue is closed (for example: Closed, Resolved, etc...)
- Add a Related Issues Condition with the parameters below: