Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Automation - Add label copied from sprint name

Marine Redon
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

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
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 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 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 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

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.
March 13, 2025

In your rule's Edit Issue action, the smart value is in the field for Labels to Remove.  Please clear that and put it in the Labels to Add field.  And then re-test.

If that does not help...please post images of:

  • the Create Variable action
  • the updated Edit Issue action
  • the audit log details showing the rule execution, with all of the expand areas on the right side > opened up
Patricia Caballero Leal March 14, 2025

Thanks for your response @Bill Sheboy 

It is not working with the changes you suggested. However, I am not sure if this is exactly what I need since we have 3 sprints: 1."Para refinar", 2."Para refinar" and the current sprint.

Only the current sprint has dates and I need to add labels only to the issues added to the current sprint after the sprint started.

I have tried many automations with conditions and also the solution you posted here, but nothing is working and I really don't know what else I can do.

 

Your help with this problem would be more than appreciated.

:) 

TEST3.png

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.
March 14, 2025

Please provide the images I noted above as something is incorrect in the implementation of your rule and seeing the images will provide context:

  • an image of your current, complete rule
  • images of each trigger, action, branch, and condition in your rule
  • an image of the audit log details showing the rule execution, with all of the areas at the right side of the log with the arrows > expanded to show the issues involved

 

When the trigger is Sprint Started, the Created Variable I described could only contain the current (active) sprint's name.

Patricia Caballero Leal March 17, 2025

Thank you for your response Bill,

I have been able to create the automation to add a label when an issue is added after the sprint started only for the active sprint so that is not added in previous stages. This automation is also removing the label when the issue is taken back from the active sprint to previous stages.

tes3.png

trigger3.pngtrigger2.pngtrigger 1.pngCaptura de pantalla 2025-03-17 110739.pngCaptura de pantalla 2025-03-17 110723.png

The audit logs are all successfull:

Captura de pantalla 2025-03-17 110608.png

The only problem I have now is that this label is not added when the issue when trough different active sprints like this:

muchos sprints.png

¿Any idea on how can I solve this last issue?

 

Thanks in advance.

 

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.
March 17, 2025

Thank you for those images.  I see two problems with the rule you show:

 

First, within an issue the sprint field is a list of values.  And the condition inside of the branch is checking {{issue.sprint.state}} That could produce a list of values, such as:

closed, closed

or

closed, closed, active

Perhaps try testing this way with the smart values condition to detect when the issue is not in the active sprint:

  • smart values condition
    • first value: {{#issue.sprint}}{{#if(equals(state, "active"))}}{{name}}{{/}}{{/}}
    • condition: equals
    • second value: leave as empty

This could also be tested more easily with a JQL condition on the issue:

(sprint NOT IN openSprints() OR sprint IS EMPTY)

 

 

Next, when a rule edits an issue in the cloud, it does not automatically refresh the data the rule holds.  And thus your update of the Labels in the branch is not visible to the rest of the rule, and so could fail the later condition.

When you want the updates to be visible, add the Re-fetch Issue action after the first edit action.

0 votes
Derek Fields _RightStar_
Community Champion
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