Automations - From Comments Create Labels - Multiple Regex Matches

Ryan Markle April 6, 2021

Hi!  

Our automation is looking at the comments to see if there is anything like ##TESTING123 and making that into a label (I have a regex match for ##).  I strip off the ## and create a label called "TESTING123".  Works good.

 

The issue i have is when there is more than one regex match (ie someone enters a comment like this "Here is a comment that contains ##TESTING123 and ##TESTING124").  I'm trying to use a smart value that contains all matches and then I want to iterate them and put them in to the issue JSON label group as such:

{
   "fields": {
       "labels": [
          "{{labelNames}}"
        ],
     }
}

My smart label name is labelNames - which, according to the logs, looks like this:  TESTING123, TESTING124

Unfortunately, this doesn't work.  I think it's because there needs to be double quotes around each value when iterating and a comma after each iteration except the last one for it to be proper JSON.  


Can anyone help me out?

1 answer

1 accepted

0 votes
Answer accepted
Eric
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 6, 2021

Hi @Ryan Markle 

 

To achieve the behaviour you want, you would need to iterate (branch) over the smart value.

Unfortunately, this is not currently supported. There's an open feature request for this: https://codebarrel.atlassian.net/browse/AUT-2023.

 

Eric

Ryan Markle April 9, 2021

For future reference, I was able to add(not update) multiple labels using the following json:

{
  "fields": {
      "labels": {{issue.summary.match("##(\w+)\b").asJsonStringArray}}
   }  
}

For some reason it didn't like me using a variable I created so I had to use the field directly

Suggest an answer

Log in or Sign up to answer