Close epic when stories are done

Use case

In this automation rule the epic will be automatically closed as soon as all stories are done.


⚒️ Configuration

Issue transitioned event

Create a new rule and name it appropriately.

Providing a description will help you to identify what the rule does but this step is optional.

Add a Trigger → Issue transitioned event

Boolean condition

Add the following parser expression:

Bash
count(issuesUnderEpic()) = count(filterByStatus(issuesUnderEpic(), "Done")) AND count(issuesUnderEpic()) != 0

This way the rule will only continue, if all issues under the current epic are in status Done.

To achieve this, the following functions are used:

Issue selector

Next to the boolean condition click on  Add → Selector → Issue selector

Target issue(s)

Linked epic

Transition issue

Next to the issue selector click on Add → Action → Transition issue

Mode

Choose Transition to status

Status

Choose Done

Enable the rule by clicking on the Enable button  rule-status-off.png →  rule-status-on.png

📤 Import the example

Import the JSON file below to get started in no time.

JSON

After importing the JSON file, make sure to check the configuration of the rule. Non-existing configuration elements (issue types, fields, values etc.) will be highlighted.

JavaScript
{
    "name": "Close Epic when stories are done",
    "description": "",
    "creator": "admin",
    "status": false,
    "triggerData": "",
    "triggerType": "ISSUE_TRANSITIONED_EVENT",
    "configuration": {
        "refs": [
            "issue",
            "system",
            "trigger.issue",
            "trigger.parent"
        ],
        "triggerType": ""
    },
    "children": [
        {
            "sequence": 0,
            "type": "BOOLEAN_CONDITION",
            "ruleEntityType": "CONDITION",
            "configuration": {
                "refs": [
                    "issue",
                    "project",
                    "system",
                    "trigger",
                    "trigger.issue",
                    "trigger.parent"
                ],
                "expression": "count(issuesUnderEpic()) = count(filterByStatus(issuesUnderEpic(), \"Done\"))",
                "expressionParsingMode": "logical",
                "actingUser": "field_00020"
            },
            "children": [
                {
                    "sequence": 0,
                    "type": "ISSUE_SELECTOR",
                    "ruleEntityType": "SELECTOR",
                    "configuration": {
                        "refs": [
                            "issue",
                            "project",
                            "system",
                            "trigger",
                            "trigger.issue",
                            "trigger.parent"
                        ],
                        "option": "epic",
                        "issueListExpressionParsingMode": "issues",
                        "actingUser": "field_00020"
                    },
                    "children": [
                        {
                            "sequence": 1,
                            "type": "TRANSITION_ISSUE",
                            "ruleEntityType": "ACTION",
                            "configuration": {
                                "refs": [
                                    "issue",
                                    "issues",
                                    "project",
                                    "selector.issue",
                                    "selector.parent",
                                    "system",
                                    "trigger",
                                    "trigger.issue",
                                    "trigger.parent"
                                ],
                                "option": "status",
                                "status": "10012",
                                "actingUser": "field_00020"
                            },
                            "children": null,
                            "hasChildren": false
                        }
                    ],
                    "hasChildren": true
                }
            ],
            "hasChildren": true
        }
    ],
    "hasChildren": true
}


📚 Related example