Issue with labels in Automation

Ankit Aggarwal December 9, 2021

I am trying to create an automation rule where each time an issue is moved to a new sprint, a new label is added with the name of that sprint.

 

More specifically, if the issue was added to a sprint that is already in progress, it should receive that label. I'm receiving the following error with the below rule. Can anyone help?

 

 Capture2.PNGCapture1.PNG

1 answer

1 accepted

1 vote
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.
December 9, 2021

Hi @Ankit Aggarwal 

That error tells you Labels cannot contain spaces, which is correct.

Without seeing the details of your edit, I am guessing that you are trying to add to Labels with {{issue.sprint}} or {{issue.sprint.name}}

The sprint field is a list, and when you use it that way it is split into individual values delimited by commas and spaces.  So you could remove the delimiters or substitute other values.

However I wonder: do you only want to add one Label for the current open sprint?  In that case you may use this expression to process the sprint list with conditional filtering to just get the active sprint's name for the label:

{{#issue.sprint}}{{#if(equals(state, "active"))}}{{name}}{{/}}{{/}}

Kind regards,
Bill

Ankit Aggarwal December 9, 2021

Thanks for the reply @Bill Sheboy . I was using {{sprint.name}}.

Capture.PNG

 

But yes, I only want to add the current open sprint to the list of labels. Where would I put the below expression?

{{#issue.sprint}}{{#if(equals(state, "active"))}}{{name}}{{/}}{{/}}

 

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.
December 9, 2021

The answer depends on whether or not you expect your sprint names will contain spaces:

  • If no spaces: you may paste that expression into the Values to add for the Labels edit.  It will appear below the field, so select it to set it.
  • If yes to spaces...You will need to remove the spaces first using a temporary variable
    • First, before your edit add an action to Create Variable
      • Name: myNewLabel
      • Smart value: {{#issue.sprint}}{{#if(equals(state, "active"))}}{{name}}{{/}}{{/}}
    • Next, use that variable in the label edit, by removing spaces
      • {{myNewLabel.remove(" ")}}
Ankit Aggarwal December 9, 2021

Genius! Thanks @Bill Sheboy , it worked!

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.
December 9, 2021

I am glad to learn that worked!  Please consider marking this question as answered to help others in the future searching for similar use cases.  Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events