Jira Automation - Add label copied from sprint name

Marine Redon
Contributor
February 17, 2025

In order to track issues added to the sprint after sprint start, I am trying to set up an automation as follows: Screenshot 2025-02-17 175617.png

{ 
"update": {
"labels": [{
"add": {{issue.sprint.last.name.asJsonStringArray.replace(" ","-")}}
}]
}
}

When the sprint is started, issues in that sprint are edited: they receive a label that is copied from the name of the current sprint.

Jira throws an error about the JSON. I have to use this because the 'Choose fields to set' does not allow me to add a new label on top of the existing ones.

On the screenshot above, it says 'The JSON is valid' but the audit log says 'Error while parsing additional fields. Not valid JSON.'

When I type:

{ 
"update": {
"labels": [{
"add": {{issue.sprint.last.name.asJsonStringArray.replace(" ","-")}}
}]
}
}

it throws the error "The label 'TEST Sprint 10' can't contain spaces. (labels))" so I suspect it's the attempt to remove spaces that doesn't work. 

Any help to make this work would be greatly appreciated.

 

 

3 answers

1 accepted

3 votes
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 17, 2025

Hi @Marine Redon 

Rather than using the JSON to repeatedly extract the value, I recommend using a variable to capture it one time (from the trigger value) and then using the Edit Issue and Labels field ... ADDREMOVE option to make the update.

For example:

  • trigger: sprint started
  • action: create variable
    • name: varSprintNameAsLabel
    • value: {{sprint.name.replace(" ", "-")}}
  • branch: on issues in the sprint
    • action: edit issue
      • select the labels field
      • select the ... at the right of the field to use ADDREMOVE
      • enter the smart value in the Values to add
        • {{varSprintNameAsLabel}}

Kind regards,
Bill

Marine Redon
Contributor
February 18, 2025

Hi @Bill Sheboy , thank you that worked perfectly. I wasn't sure how variables worked but that solved the issue. 

For anyone else reading, it did not remove prior labels and it only added the current sprint as label, even if the issue had been in several sprints before.

Like Bill Sheboy likes this
Patricia Caballero Leal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 13, 2025

Hi all,

 

This is exactly what I need to do but I am not sure if I am doing it on the right way since it is not working to me.

 

Can someone check what am I doing wrong?

 

Thanks

 

0 votes
Patricia Caballero Leal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 13, 2025

Hi all,

 

This is exactly what I need to do but I am not sure if I am doing it on the right way since it is not working to me.

 

Can someone check what am I doing wrong?

 

Thanks in advancetest2.png

0 votes
Derek Fields _RightStar_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2025

You can add additional labels by using the smart value {{issue.labels}} and the label that you want to add. See the following. This works in my testing.

2025-02-17_13-21-11.PNG

Suggest an answer

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

Atlassian Community Events