Forums

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

Automation: Find children of Epic, add their key to parent's comments

Fred
Contributor
April 29, 2022

I have an epic with issues in it. I'd like an automation that will:

- check if this epic contains issues

- add a comment with those issue keys

From there, another automation will add 'relates to' links to those issues.

 

The epics will eventually be converted to tasks, and I'd like to keep a link to the children.

 

Variations on this failed for me. 

I'm an admin, and have scriptrunner if it helps.

 

Thanks for any pointers!

1 answer

1 accepted

1 vote
Answer accepted
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.
April 29, 2022

Hi @Fred 

You note that you have an automation rule and that it failed to do what you wanted.  Would you please post images of the rule and the audit log details, showing where it did not work as expected?  That may help the community to offer suggestions.  Thanks!

Kind regards,
Bill

Fred
Contributor
April 29, 2022

Below is what remains. I scrapped the rest because it failed.Screen Shot 2022-04-29 at 4.28.21 PM.png

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.
April 29, 2022

Thanks, Fred.

That seems a bit different from what you described...perhaps that rule is assuming part of the problem has already been solved?

You noted two steps: 

  1. for an Epic with child issues, gather the child issues' keys into a comment.  (I suspect you could also skip rule #2 and just add the links immediately.)
  2. later after the epic has been converted to a Task, use the comment to add links to the previously child issues

Your first rule could be:

  • trigger: manual 
  • condition: issuetype is epic
  • action: lookup issues with JQL of "Epic Link" = {{triggerIssue.key}}  This assumes a company-managed project.  Substitute "parent" for "Epic Link" if this is a team-managed project
  • advanced compare condition: check if there are any children
    • first value: {{lookupIssues.size|0}}
    • condition: greater than
    • second value: 0
  • action: add comment, such as

"Here are the children to link later: {{#lookupIssues}}{{key}}{{^last}},{{/}}{{/}}

Fred
Contributor
May 2, 2022

Bill, that works perfectly, thank you! Has the syntax for this solution changed? It's not working on our instance, and seems like it's failed for others. 

Screen Shot 2022-05-02 at 12.27.38 PM.png

It says 'The following issues did not match the condition:' which is the trigger issue.

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.
May 2, 2022

Hi, Fred.  I have not tried the rule in that post so I cannot confirm any changes.  Perhaps that regular expression is sometimes not matching for other reasons, such as...

In answering another question about extracting links from the description, I found they are stored as "smart links" in the markup.  Perhaps the same is true for the comments markup.  You can confirm this by writing the comment body to the audit log.

https://community.atlassian.com/t5/Jira-questions/Create-automatic-linked-issues-when-writing-an-ticket-number-in/qaq-p/2014794

One other work-around is to store the keys in the comment with the first rule such that they cannot be turned into links, such as adding spacing around the hyphen in the key.

Like Quentin Schneider likes this

Suggest an answer

Log in or Sign up to answer