For linking all issues in the a specific project mentioned in the description I figure I should use the .match command. For me it's the IFIP project.
To reduce false-positives, I use the regex [1-9][0-9]{0,7} to ensure the first digit isn't a 0, and there's up to 8 digits in total after the project key.
With or without the quotes, this fails to put a value into the ifipTicket smart variable (see screen shot). I think the single curly braces are an issue, but they are correct regex syntax.
{{issue.description.match("\b(IFIP-[1-9][0-9]{0,7})\b")}}
The same regex syntax correctly identifies the Jira key in a filter step (see attachment), but provides a null string when used in the .match
What am I doing wrong? Do I need to escape the single curly braces, or have I just plain missed something?
I suspect that one, or more, of the regular expression constructs you are using may not be supported. As the documentation states, with emphasis added by me:
The underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches.
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--
I recommend starting with the simplest expression that can possibly meet your needs, testing that, and then incrementally adding more constructs until it stops working. That will identify the problem and allow making adjustments.
This could also be the parsing order of the match() function, which I have seen solved before by first saving your regular expression in a variable, without quotation marks, and then using it in the match as:
{{issue.description.match(varRegEx)}}
My quick testing showed word-boundary worked and that {0,7} did not, even with escaping the curly brackets.
Kind regards,
Bill
Using your regex in a variable idea I've got this working. The curly braces did indeed cause an issue, as did several other regex syntax until I landed on this in the variable I named theRegex:
"\b(IFIP-[1-9][0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?)\b"
The ifipTicket variable then uses the following:
{{issue.description.match(theRegex)}}
The result is the/each IFIP ID, twice, which I then split and get the distinct vale(s) from.
{{ifipTicket.split(", ").distinct}}
I now need to split that and iterate through to add links to each IFIP ID, which for anyone trying to do something similar, is done like this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.