Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I transition the parent when all subtasks are resolved with Automation for JIRA?

andreas
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.
January 2, 2017

Using Automation for JIRA is it possible to transition the parent when all subtasks are resolved?

4 answers

1 accepted

18 votes
Answer accepted
andreas
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.
January 2, 2017

This is definitely possible using the related issues action and condition:

Project automation - Code Barrel JIRA 2017-01-03 16-54-19 (2).png

Lets break this rule down:

  • Trigger: When any issue in this project is transitioned
  • First check using the 'Compare' condition that it was a 'Sub-task'.  You could also use a JqlCondition here too. 
  • Then: We use the related issues action to branch the rule for the 'Parent'
  • And on this branch we use the 'Related issues condition' to check that all sub-tasks of the parent match 'status = Done'
  • Finally if that condition is true, then the 'Transition Action' will transition the parent to 'Done'

 

Russ Watson-Thomas January 9, 2017

Hey Andreas,

Just expanding on this a little bit... I use multiple different subtask types. Is this powerful enough to differentiate? i.e. I can pick the subtask type I want to compare and then trigger a parent transition (and or do this via a filter searching for those subtaskIssueTypes())?

If so, that's incredibly powerful for me! smile

andreas
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.
January 10, 2017

Hey Russ,

Yes you can certainly do more filtering.  We don't support else statements yet, so right now you'd have to setup multiple rules.  

In the rule shown above you'd simply insert another condition before the "Then: For Parent" action.  You could use a JQL condition for example to test "type = myspecialsubtasktype" (or any JQL really). If the sub-task that was transitioned matches then the rule will continue and transition the parent.  If it doesn't then rule execution will stop.

You can also add more conditions in the "Then: For Parent" branch to for example only transition the parent if it is of a specific type/JQL match.

Setting up multiple rules is simple - you can just got to 'Create rule' -> 'Copy rule' to copy an existing rule if you just want to change the condition.  We'll add proper 'else' support in future but for now this should work as well.

If you can describe a more specific example I'm happy to provide an example rule as well.

Cheers,

  Andreas

Russ Watson-Thomas January 16, 2017

Hey Andreas,

Thank you for the reply, it's massively useful. Here is a full on use case:

1) I have multiple subtasks (i.e. Dev Task, Test Task, Documentation)

2) Each has it's own workflow

3) Parent's have their own workflow

Use Case:

Update Parent from Waiting for Dev to In Dev when any Dev Task is not new

Current thought: One automation rule that says Transition Parent to In Dev when JQL filter says dev tasks status is not new

Update parent to waiting for test when dev tasks are closed

Current though: another rule that says transition parent to Waiting for Test when JQL filter says all dev tasks closed

 

I guess the bit I find a little tricky right now is iterating over multiple subtasks to say 'all in status' .. but it looks like there's a rule in the compare bit that does this.. Could you help clarify this for multiple different task types? Just multiple rules?

andreas
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.
January 17, 2017

Hey Russ,

So you can do this as separate rules, or you can do it in a single rule as well.  Here's an example:

transitionparent.png

So what I have is 2 related issues actions 'For parent' with a related issues condition that uses JQL to find all sub-tasks of a given type parent = {{ issue.key }} and type = "Dev-task"  and then checks if some of them are in progress, or all are done respectively.

If some are in progress, I transition the parent issue to "In Progress".  If all are Done I transition the parent issue to "Waiting for deploy"  (in your use case this would be the "Waiting for test" status, but I didn't want to edit my workflow as well - you get the idea smile ).

Hope this makes sense!

andreas
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.
January 22, 2017

Hey everyone,

Just letting you know that with the latest release of Automation for JIRA this is now a bit easier:
https://blog.codebarrel.io/better-transitions-and-simpler-scheduled-triggers-90b4b991b778

The improved Transition action now also supports smart-values and some special values like 'Copy from issue', 'Copy from Epic' etc.

Cheers,
  Andreas 

Dimitri Zetzsche February 2, 2017

I already mailed this to @Andreas Knecht, it's maybe useful for someone else who is looking for the answer:

My use case 

I want to close User Stories when all Linked issues are closed. The difference with the example in this threadis that I have linked issues instead of sub-task. I thought it wouldn’t be a problem since the related issue condition supports Linked issues.

I have following test case set up:

  • USER story HOR-938 with  status = open
    • contains (= issue links) HOR-939 ( issuetype = task, status = open)

When I transition HOR-939 to status Closed I see in the audit log that the flow triggers but returns an error. Maybe I misunderstand something in the JIRA architecture but:

  • HOR-939 has a parent
  • The parent is a user story which has linked issues.

Screen Shot 2017-02-02 at 11.20.50.png

 

My workflow

Screen Shot 2017-02-02 at 11.26.15.png

 

EDIT:

I tried the same with now using the concept of "sub-tasks" and it works fine. However I wonder if it would also work with "linked issues". Maybe my use case with linked issue fails because there is no "parent-concept" with linked issues?

EDIT2:

I managed to get it working with linked issues. Like I already mentioned in my first EDIT with linked issues there is no parent concept. I took a different approach in my automation flow:

 Screen Shot 2017-02-02 at 18.24.36.png

Cheerio 

Dimitri

andreas
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.
February 2, 2017

Hey Dimitri,

Nice work! Yes, for linked issues the 'Related issues' action needs to use 'linked issues'. The parent and sub-task options only work for those types of relationships.  

Cheers,

  Andreas

phil huynh April 4, 2017

Hi Andreas,

 

Im trying to do something similar.  above you wrote...

So what I have is 2 related issues actions 'For parent' with a related issues condition that uses JQL to find all sub-tasks of a given type parent = {{ issue.key }} and type = "Dev-task"  and then checks if some of them are in progress, or all are done respectively.

I dont understand the part where you sday check if all are done. I dont see how you check if all the returned jql items are done.  Im to the part where i can select my subtasks of certain type.  But i dont see how to run the condition against the returned subtasks.  Im probably overlooking something simple.

andreas
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.
April 4, 2017

Hey Phil,

So what you need is a 'Related issues condition'. It allows you to check if any, all or no issues match a given JQL.

See https://codebarrel.io/available-rule-components#related-condition

So you could use this to check if all sub-tasks of a given type match: 

parent = {{issue.key}} and type = "Dev-task" and status = Done

Hope that makes sense!

Cheers,

  Andreas

KS April 20, 2017

Hello,

maybe someone can help. I have a task with many sub-tasks. I need to transition task to status Closed once all sub-tasks are closed.

I reproduced the automation rule provided at the very beginning (Project automation - Code Barrel JIRA 2017-01-03 16-54-19.png ‏278 KB), but still that doesn't work. I get error: Error searching for related issues. This is most likely because the following issues don't have a related issue of the type you specified. Try narrowing your search to only include issues that contain links to related issues:
API-942

 

Please advice

andreas
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.
April 20, 2017

Hi Krystsina,

Can you post a screenshot of your rule showing the 'related issues' action configuration please?

You can also do this in support via https://codebarrel.io/support if you don't want to post your rule publicly here.

Cheers,

  Andreas

 

KS April 21, 2017

Hello Andreas,

please find screenshot below.

automation.png

andreas
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.
April 25, 2017

Hi Krystsina, 

This should work I think.  Lets move this to https://codebarrel.io/support please - I don't want to dillute the question here with providing support.

Can you raise a support request please, and include screenshots with your audit logs as well, showing what went wrong?

Can you also include screenshots of the issue that was transitioned, showing its 'History' tab please?

Cheers, 

  Andreas

KS May 3, 2017

Hello Andreas,

I found an issue. It seems that in case you have transition 1->2->3 it won't allow you to automatically go from 1 to 3.  You have to automate 1->2 and 2->3

 

Thanks!

Vrushali Yewle October 3, 2017

Hi Andreas

How do I know that the syntax for saying "issuetype = sub-task" is {{issue.fields.issuetype.name}} = Sub-task? How do I know that is isn't just {{issue.issuetype}} = Sub-task? Is there a syntax manual? I went through your documentation but I did not find an exhaustive list.

I can always use JQL, of course. But this mustache syntax has me curious.

andreas
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.
October 3, 2017

Hey Vrushali,

So https://codebarrel.atlassian.net/wiki/spaces/AUTO4J/pages/27656216/Smart+Fields is the best place to look for this currently.

It isn't an exhaustive list as you mentioned though. It's kind of hard to compile such a list, due to sheer number of different field types and field attributes available in Jira.

If in doubt I'd say use a JQL condition.  We do have plans to make smart-values easier in the product in future through some sort of autocomplete (https://codebarrel.atlassian.net/browse/AUT-104).

Cheers,
  Andreas

Jimmy January 22, 2018

Hi Andreas, 

I posted the following 2 questions as a comment on your Medium post but I just found this thread too so I'll paste them here as well. 

I’m a new JIRA Core (Cloud) user and Automation for JIRA user. The “ Related Issues” condition looks pretty awesome and seems like what I’m looking for. I have 2 questions:

  1. I’d like my Sub-Tasks to All match specified JQL where (in pseudo-code) “status is equal to any type of Done value”. And by that, I mean that in JIRA, if I understand correctly, there’s the default “Done” status, but also a bunch of “Done” equivalents, such as (a) the system built-in ones “Closed”, “Resolved”, and (b) custom statuses that I’ve defined and mapped to the system Done state. How do I specify the JQL to match either all of set (a) or all of set (b) or both sets (a) and (b)? Maybe something like status in (Done,Closed,Resolved,myCustomDoneStatus1,myCustomDoneStatus2)?
  2. Just to further complicate matters, I’ve translated some statuses to Chinese. Does JQL in general match the translated values or just the original values, or both? What if my original value of a custom status was not entered in English but directly in Chinese (and thus does not have a translated value, but just has an original value that’s non-English)? I would hope that JQL in general matches the original non-translated value, and is able to match international character sets — would just like to confirm this behaviour.

Hope that my questions are clear enough. Thanks!

andreas
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.
January 22, 2018
Jimmy January 22, 2018

Thanks! statusCategory = Done was exactly what I was looking for. I also didn't know there was an issue navigator, indeed very useful for building and testing JQLs.

Marcelo Ignacio Cid Abud August 8, 2022

Hi @andreas 

I need your help

How can I do this automation in the opposite case? That is, when the history passes to the discarded state, all the subtasks (that were in progress) are moved to discarded and those that were in the backlog are eliminated?

0 votes
Srikanth Mamidala April 2, 2020

Please ignore my earlier message, I was able to figureout what was wrong. Its my mistake . This raises another question for me is that

 

Can we include multiple subtasks inthe "Second value" option of the if condition? 

My end goal is, when someone creates a issue and transition to a 1st status, it needs to create multiple subtasks,  and when all the subtasks are complete it should move to next status where another bunch of new tasks are created and when subtasks are closed again move to next status and so on. 

I was successful in using automation for this and tested with one subtasks at one transition using this, but I would hate to create multiple conditions. I could use special string for all sub tasks and use contain option in if compare. 

 

Just wanting to know what the best recommended approach/solution to achieve this. 

second.PNG

0 votes
Srikanth Mamidala April 2, 2020

Hi Guys, 

I am trying to achieve the same thing in question with no success. Attached is the rule, I am not sure if I am doing it wrong because from the first screenshot which andreas posted, mine doesnt look same 

1. I could not find compare 2 values option but mine just says match 2 option

2. It doesnt let me add a new action of the parent at the same root after I used if statement

I am not sure if anything has changed with regard to the version I am using. 

Please advise. JIra.PNG

0 votes
Zehra Atmaca August 29, 2018

Hi all,

 

I am struggling in automating to automatically close the parent if all linked issues via link type "Forwarded" are Resolved.

I've already tried with JMWE and Automation for jira but unfortunately without results...

 

Have somebody experience with that?

 

Any idea will be welcome

Thanks 

Kind regards

Michele VS February 23, 2023

Using Subtask (Test Executions) for Parent Use Test Cases

Automation seems to work and I receive notification but parent status isn't updated as soon as all subtasks are Passed.. seems to be a delay. I need to either refresh screen or exit to see the parent Use Test Case status updated to Passed.

Using this rule because testers forget to update parent when all tests are passed 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events