JIRA JMWE Groovy - how to check the summary of linked tickets

Sina Esfahani September 8, 2020

I am working with JMWE and trying to write a groovy script where I want to check the summary of the linked tickets and if they do not contain the word 'auto' anywhere in the summary title... it will create a new ticket. I've tried many different combinations and haven't been able to get it to work. 

2 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 8, 2020

Do you want to create one new issue per linked issue that doesn't contain the word "auto" in the summary, or do you want to create a single new issue if none of the linked issues contain "auto" in the summary? Derek's solution above answers the former - for the latter, you'll need to use the "Conditional execution" feature with this script:

!issue.getLinkedIssues().any { it.summary.toLowerCase().contains("auto") }

Also, that will check all linked issues, but not sub-tasks or issues in an Epic. So the code really depends on what you need. 

Sina Esfahani September 12, 2020

David, this is exactly what I was looking for! It is the latter. I also have another use case to look for any linked issues where the issue type is documentation. Is this correct? It seems to have worked after testing it.... 

!issue.getLinkedIssues().any {it.issueType.name == "Documentation"}

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 13, 2020

That will work. Or if you know the link direction name (as it appears on the issue), you can do:

! issue.getLinkedIssues("has documentation")

which will return true if the issue doesn't have any issue linked to it through the "has documentation" link type direction.

Kris Han May 17, 2021

Hi @David Fischer ,

Sorry to bother you,

How should I write the same code but for issue in Epic? I faced the same problem but my linked issues are under issue in Epic. Thank you very much!

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2021

Hi @Kris Han ,

it's actually documented in the Issue Methods help tab, but here it is:

issue.stories
0 votes
C_ Derek Fields
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 8, 2020

You can use the JMWE Post-Function "Create / Clone Issue(s) Post-function". Check the box "Multiple Issue Creation" In the "Iterator" field, paste:

issue.getLinkedIssues().findAll { ! it.summary.toLowerCase().contains("auto") }

This will return a list of linked issues that do not contain the word "auto". This will then allow you create a new issue for each one that is returned in the iterator.  

Suggest an answer

Log in or Sign up to answer