Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Using Jira Automation to label tickets in a sprint using a sub-string of the Sprint Name

Hi, I'm looking help to set up a JIRA Automation rule that will label all tickets in a sprint (on sprint start) with a  substring of characters from within the sprint name. 

The desired label is to be "PI XX.X" where X represents a number and this could occur anywhere in the sprint name.

I have created an automation rule that will work (on sprint start) if this desired substring appears as the first 7 characters in the sprint name, but I want to make this more versatile to be able to find this substring wherever it occurs in the sprint name. 

"update": {
"labels": [{
"add": "{{, 7).replace(" ", "_")}}"

I have been looking into resolving this with REGEX pattern matching, and have a REGEX pattern that will find the required substring, but I've not yet been able to use this Match to create the desired label:

"update": {
"labels": [{
"add": "{{\s\d{2}\.\d)}}"


1 answer

1 accepted

0 votes
Answer accepted

Hi @Nigel Clulow 

As the sprint field is a list, I wonder if using match() is potentially also producing a list of results.  Try writing that smart value with the regular expression to the audit log to see if that is the case.  If so, perhaps then referencing just one item from the list would meet your need.

Kind regards,

Hi Bill, thanks for your reply. I've not made progress with the MATCH approach, so I was wondering if there is a way to use Substring with Indexof and a set length? For example, find the Index of the string "PI ", and use this index as the starting parameter in the Substring function? The second challenge with this is the End INT needs to be this Index Value + 7.

I've come back to this as labelling from the substring extract worked, but was limited by the desired text needing to be at the start of the sprint name.

My testing in other rules indicated that smart values could not consistently be used as parameters to functions like substring.  There is something about the order of evaluation that seems to lead to nulls in the middle, breaking the calls.

I recommend giving match() another try, perhaps by first listing examples of what the sprint name could contain, and then practice writing the expressions to the audit log.  Once you have something that works, try to add the labels with it.  The tricky part of this is the regular expression, as the help indicates:

The underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches.

And I recall seeing several things defined for the Java implementation of regular expressions which are not supported by automation rules in match().  Try simpler expressions, when possible.


Also, I do not believe you need to use JSON to add a label with smart values; instead you can type in the expression with Edit Issue, Labels, add label...the smart value will appear below the field when you type it, and then you may select it for use.

Hi @Bill Sheboy , thanks for your input.  I've managed to create a working rule using MATCH():

"update": {
"labels": [{
"add": "{{".*(PI.....).*").replace(" ", "_")}}"

This Identifier + Wildcards lifts the desired text string and uses that to create the label:

Action details:

Edit Issue:
Issues edited successfully
Match value is: "PI_22.4"
Sprint name is: "team 2 - PI 22.4 - Sprint 3"

Tightening up the pattern matching to look specifically for PI XX.X would be great to remove the risk of "PI" occurring earlier in the sprint name before the desired label, and any guidance you might have on that aspect would certainly be appreciated. 

One concern is how are the sprint names created.  If there is another automation rule/script creating them, you could rely on a stable format.  But if they are manually created it is certainly possible you could have multiple or no matches.

If your names are automatically generated and always match the pattern, your expression is probably fine.  However once you get past (what I assume to be) two-digits in your Program Increment number, this will break.  So you could instead assume \d doesn't work in the rule implementation of regular expressions, and try something like this:

match(".* (PI [0-9]+\.[0-9]) .*").replace(" ","_")

Unforuntately sprint naming is a manual action so is still open to associated formatting risks. When naming a sprint, the requirement will be to use the tag "PI XX.X"  somewhere in the sprint name, however the benefit of this match() approach is this can now appear anywhere in the sprint name, and not be constrained to the start of the name as was the requirement for the substring rule. 

Testing your suggested pattern match against the initial rule, I've noticed both address the concern I had, namely that the presence of "PI" earlier in the sprint name would be sufficient to trigger the Match, and therefore create an incorrect Label, but both work correctly

Edit issue
Issues edited successfully
Log action
Match value is: "PI_22.5"
Log action
Sprint name is: "PI team - PI 22.5 - Sprint3"
I need to understand the wildcard criteria better, but this seems to meet the need so far. Thanks for your help. 

Like Bill Sheboy likes this

I keeping thinking about creating a test rule (or rules) to exercise the regular expression functions to pin this down: what works and does not.  Gotta find some free time to do it.  :^)

Yes, I was surprised by the result of this 'negative' test. For the for the sake of time, i'm accepting this works though as you say, I would like to better understand the operation of this regular expression. Thanks for your help with this. 

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events