Automatically link new Issues to Existing Issues based on Alphanumeric Code in summary

Robert Arcolas February 11, 2025

Hi All,

I'm trying to autolink issues based on a 6 digit alphanumeric code that will be found somewhere in the Summary. Some examples of the possible summaries (with XXXXXX being the alphanumeric characters, IE (A-Z, 0-9):

XXXXXX | Bla bla bla

Bla bla bla / Bla bla bla / BK#:XXXXXX / Bla bla bla

Bla bla bla: #XXXXXX

I have been able to successfully get this to work if the code in the summary is all digits (8 digits in this case): 

Compare 2 smart values:
First Value: {{issue.summary}}
Condition: contains regular expression
Regular expression: .*\d{8}.*

Then Create Smart variable
Variable name: numberInSummary
Smart Value: {{issue.summary.match(".*(\d{8}).*")}}

Then match JQL and then link issue to the trigger issue

 

 

However i'm stumped when it comes to the regex to find 6 alphanumeric characters especially since there are words in the summary with 6 letters and i don't want to match to those, only 6 digit alphanumeric.

i've tried using the compare regular expression as
^[a-zA-Z0-9]{6,}$

and the smart value as
{{issue.summary.match(".*(^[a-zA-Z0-9]{6,}$).*")}}

but that doesn't work and I don't know how to write the correct regex.

 

Thanks in Advance!

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.
February 11, 2025

Hi @Robert Arcolas 

Short answer: please try using the simplest regular expression that can possibly work, testing fully, and then add edge cases.  Perhaps even use the other text functions to help.

 

For more information...

This is no automation rule documentation on what actually is (or is not) supported by regular expressions for the match() and replaceAll() functions.  Here is what the docs state, with italics added be me:

match()

Performs a regular expression search and returns the first (and only one) matching regular expression group.

The underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches...

You can search and find many community posts where people tried regular expressions which worked in other parsers that did not work with rules.  Thus experimentation is key.

 

For your scenario, you note wanting "to find 6 alphanumeric characters especially since there are words in the summary with 6 letters and i don't want to match to those, only 6 digit alphanumeric."

Does that mean you want strings with 6-and-only-6 characters, and which have at least one digit so they are not a human-readable word in the Summary?

If so, you could try chaining together multiple match() calls, using simple regex to avoid problems.  Perhaps like this:

{{issue.summary.match("\\b([A-Za-z0-9]{6})\\b").match("(.*[0-9]{1,}.*)")}}

For other fields with formatting (e.g., Description) the match() function has trouble with newlines.  If you need to process those, consider using a replace("\n", " ") before attempting a match().

 

Kind regards,
Bill

Robert Arcolas February 11, 2025

I updated the automation using your suggestion and all is well.

Thanks for the help Bill!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events