Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Jira automation to close epic of story "and" sub tasks

Chris S_ August 23, 2024

Hello community,

About closing epics when child issues are closed, what branch rule can cover "both" Epic->story and also Epic->sub task?

This rule works if stories (or bugs) are 'completed':

story.png

 

 

And this works for closing an epic when the child issue is a sub task:

 

subtask.png

 

These are two different branch rules, 1) For Epic (parent) and 2) For Parent.

Though how can an Epic with, for example, 1 story child and 1 sub-task be closed?  (where the sub task is directly of the epic, not of the story)

  • The 'For Epic (parent)' branch does not seem to recognize sub tasks as a  direct child type.

The desired result is epic is transitioned to complete, when either the story or the sub task is transitioned to complete.

 

Thank you,

Chris

 

1 answer

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2024

Hi @Chris S_ 

For Jira Data Center, there is no branch that spans both types as there are different linkages for epic -> story and story -> sub-task.

You may address this using an if / else condition and branches inside.  For example:

  • trigger: issue transitioned to Complete
  • if / else condition:
    • field condition: issue type equals story
    • branch: to epic parent
      • related issues condition: check if all sibling stories are Complete
      • action: transition the epic parent
  • else / if
    • field condition: issue type equals sub-task
    • branch: to parent (i.e., the story)
      • related issues condition: check if all sibling sub-tasks are Complete
      • action: transition the story

With Jira Cloud, a rule like this is simpler (in theory) as the parent field is used for the relationships of both.

Also...do you want this to be recursive, in that the completion of a sub-task could lead to completion of the grandparent epic?

Kind regards,
Bill

Chris S_ August 26, 2024

Hi @Bill Sheboy, Let's say an epic has 1 story and also 1 sub-task (direct child of the epic), if the story is marked complete first, then the epic should not transition, since the sub-task is still open.  However, once the sub-task is also transitioned to complete, the epic should now automatically transition to complete.  The challenge is how to  validate both conditions before transitioning the epic.

 

thank you,

Chris

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 9, 2024

Hi @Chris S_ 

Sorry for the delay in responding as I have been offline for a few weeks.

First, I believe sub-tasks are children of Story, Task, and Bug issue types, and not of Epic ones.  Let's assume you meant the Epic has one or more Stories, each with zero-to-many Sub-tasks.

To validate all of them are completed before transitioning the epic, you would need to gather the keys of all of them first and test them.  I believe that can be done using the Lookup Issues action and the Related Issues Condition.  Please validate this with testing as I am using Jira Cloud, and not Server / Data Center version.

 

For example, let's assume the trigger issue is a Story:

  • trigger: issue transitioned to complete
  • condition: issue type is Story
  • action: lookup issues, to gather the other children of the Epic with JQL
"Epic Link" = {{triggerIssue.key}}
  • action: create a variable to parse out the child and grandchild keys of the Epic
    • name: varKeyList
    • smart value:
{{#lookupIssues}},{{key}}{{#subtasks}},{{key}}{{/}}{{/}}
  • Related Issues Condition: using the variable, create JQL to gather all of the Story-level and Subtask-level issues, testing no issues are still incomplete  (i.e., none found)
key IN ( {{varKeyList.substringAfter(",")}} ) AND statusCategory != Done
  • branch: to the epic parent
    • action: transition  the issue

 

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.12
TAGS
AUG Leaders

Atlassian Community Events