Forums

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

Automation to link exact match

Terry McCuin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 8, 2025

Need help with this.  I'm using regex in an automation to link issues mentioned in the description.  The problem I'm having is that it is linking wrong issues on certain projects. 

For instance:

IM-5 will link an issue from another project IMXXXX-5

Is there a way to prevent this from happening?

Here's the regex that I am using. (sorry...can't provide screenshots)

WHEN: value changes for: Description

IF: Compare two values:  Check if {{issue.description}} contains regex ([A-Z][A-Z0-9]+-\d+)

THEN: Link issue to:  {{issue.description.match("([A-Z][A-Z0-9]+-\d+)").distinct}}

3 answers

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.
July 8, 2025

Hi @Terry McCuin -- Welcome to the Atlassian Community!

What is an example of the Description field value where it links to an incorrect project?

 

And, the result of that match() function is a list of values, and if it finds multiple I would expect the Link Issue action to fail.  Are you expecting one-and-only-one match to be found?

 

Finally, rather than using a generic regular expression, if this rule is only in one project and linking to issues in that project, you could first create a variable for the regex using the key, then use that dynamic regex in the match:

  • action: create variable:
    • name: varRegEx
    • smart value: ({{issue.project.key}}-\d+)
  • something using the match...
    • {{issue.description.match(varRegEx).distinct}}

 

Kind regards,
Bill

Terry McCuin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 9, 2025

Never tried using the variable like that.  I'll have to give that a try.

Not looking for a one on one.  There are times where multiple work items are listed in the description and all of the mentioned items should be linked.

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.
July 9, 2025

Your question has tags for Jira Server and Data Center.  If you are using those versions, adding the multiple links may not be easily possible...

Those versions of automation rules do not support Advanced Branching over smart values (such as the list of links to add), and the REST API endpoint for creating an issue link only supports one at a time.

 

A brittle workaround is to use two rules, where one is recursive:

  • first rule identifies the issue links to add, and then calls another rule using the Send Web Request action to trigger an Incoming Webhook triggered rule, passing the keys of issues to link
  • the second rule with the Incoming Webhook trigger...
    • consumes one key-pair from the list to add the link
    • check if there are any pairs remaining
    • and if so, calls itself with the remaining pairs using Send Web Request

 

Like Terry McCuin likes this
Terry McCuin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 9, 2025

Wow.  That's awesome and I never would have thought of doing it that way.  I"ll have to work on that.

Like John Funk likes this
0 votes
Shawn Doyle - ReleaseTEAM
Community Champion
July 8, 2025

Hi @Terry McCuin 

The regex looks good to find the Jira work item. 

While I'm not sure about the match function in the THEN clause, I would expect if it didn't work it just wouldn't link anything and not link some work item in another project.  I find that past suspicious and expect something else is happening. 

 

Terry McCuin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 9, 2025

Yeah.  I'm thinking Ghost in the Machine here.

Like John Funk likes this
0 votes
John Funk
Community Champion
July 8, 2025

Hi Terry - Welcome to the Atlassian Community!

So the problem is that it should only link to issues in the same project? If so, is the Rule only restricted to a single project? Or is it global? Check the Rule Details page. 

Terry McCuin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 9, 2025

It is a global that is shared through all the projects.  Not necessarily that it should link to only the same project, but to link only exact match of the work item listed in the description.

Like John Funk likes this

Suggest an answer

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

Atlassian Community Events