What I am trying to do is grab the labels from an issue and then use regex to look for a pattern and if it is there assign the sting to a variable. As you can see below I am using a Restful call to grab an issue. I have:
parentLabels = {{webhookResponse.body.fields.labels}}
filterByRegEx = {{parentLabels.match("PI-[0-9]+-[0-9]+")}}
and as you can see below I write the values of these two vars out to the log.
The parentLabels looks good but there is nothing in filterByRegEx. I know I have a string in parentLabels as I can successfully substring out what I am looking for when I hardcode the start and end. ( I am looking for "PI-3-24")
What dumb newbie mistake have I made?
Hi @Guy Slade -- Welcome to the Atlassian Community!
I see two things to adjust in your rule:
First, a created variable is plain text, and when the labels are added, by default the list flattens out to a comma-and-space separated values list. To feed them into match(), they must be split back apart with split(", ") into a list.
Next, I believe the match() expression will need a group for this case.
Putting those together:
{{parentLabels.split(", ").match("(PI-[0-9]+-[0-9]+)")}}
Kind regards,
Bill
Thanks yet again Bill! That worked a treat. In case anyone else is going down this path, the last part to this was the advanced update that was required. What worked for me was the following:
{
"update": {
"labels": [
{"add": "{{PITargetLabel}}" }
]
}
}
Where PITargetLabel was my variable that is set using Bill's code above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.