Hi everyone,
I’m setting up an automation rule to automatically link related issues between two projects — a team-managed (MIP) and a company-managed (MPD) project.
Each issue has a label in the format ws:<stream>, for example:
ws:branding
ws:dns
ws:integration
In my rule, I’m iterating over all MIP child issues under an epic, and I want to extract the ws: label from each issue to find its matching MPD issue (with the same label).
Here’s the relevant part of my rule:
Branch: parent = "{{userInputs.mipEpicKey}}"
Create variable:
{{issue.labels.join(",").match("(ws:[^,\\s]+)").first}}Log:
Found wsLabel={{wsLabel}} on {{issue.key}}However, in the audit log, the wsLabel variable is always empty:
Found wsLabel: for MIP-123
Found wsLabel: for MIP-234
Found wsLabel: for MIP-345
All these issues definitely have labels, so I’m confident the data is there.
I also tried escaping the colon like this:
{{issue.labels.join(",").match("(ws\\:[^,\\s]+)").first}}but it still returns nothing.
What I’ve checked
Confirmed {{issue.labels}} returns all labels (it does).
Tried contains("ws:") and that works, but I need the exact match (e.g. ws:branding).
Tried several variants of the regex (ws:.*, ws\\:.*, etc.).
The rule scope includes both projects.
Question
Has anyone successfully used match() in Automation for Jira with labels that include a colon (:)?
If so, what regex syntax or workaround did you use to extract the label value?
The end goal is to use that ws: label in a Lookup Issues JQL, e.g.:
parent = "{{userInputs.mpdEpicKey}}" AND labels in ("{{wsLabel}}")Any help or examples would be appreciated!
Thanks,
Daphne
Hey Dafny
I tried the below and worked for me, check it out:
Test Rule
Result
Audit log showed:
Labels raw: ws:branding
Matched wsLabel: ws:branding
Hope this helps!
Hi Christos,
Thanks so much for the prompt reply and the detailed example! I set mine up exactly the same way, including the labelsNormalized variable and the same .replace() expression.
Each of my tickets has a few labels but only one ws: label (for example: customer-implementation org-acme parent team:cs ws:branding). When the rule runs, the log still shows all labels instead of just the ws: one:
Found wsLabel: customer-implementation org-acme parent team:cs ws:branding
Because of that, the lookup step doesn't find a match in the MPD project, so nothing gets linked.
parent = "{{userInputs.mpdEpicKey}}" AND labels = "{{wsLabel}}"Here is a screenshot of my current rule setup and the audit log. Any ideas why it's still returning the full label list instead of just the ws: one?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Daphne Casal
You are right, it needed more checking, regex has its own mind
try this in the variable:
| {{issue.labels.join(" ").replaceAll("^"," ").replaceAll("\\sws:","|ws:").replaceAll("\\s[^|]+","").replaceAll("\\|",",").replaceAll("^,|,$","").replaceAll(",{2,}",",").trim}} |
worked for me in many combinations in Labels
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First things first: there is no documentation on what is (or is not) supported for regular expressions used by automation rules. Instead, it states the following, with emphasis added by me in italics:
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...
There are many community posts indicating regex that works in other contexts does not work in rules. Thus, I recommend using the simplest expression that can possibly work, always experimenting to validate, and then incrementally adding any edge cases. And for complex regex, try storing that in a created variable before using it in a match() or replaceAll() function.
Back to your question, as the Labels field is a list, you may use this expression to find any matching labels which start with "ws:"
{{issue.labels.match("^(ws:.*)")}}
That will produce a list as a result. If you first want to test for the existence of any values, check the list size is greater than 0. You described expected one-and-only-one value, so perhaps compare to 1.
Then to get that exact single value, use the first function:
{{issue.labels.match("^(ws:.*)").first}}
Kind regards,
Bill
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.