Get active sprint name in smart value for automation

Jason Anthony Montilla January 7, 2021

I have a few issues that get moved from sprint to sprint. Because of that, the "sprint" list ends up being an array of names. My ultimate goal is to figure out which active sprint a certain issue ends up moving to a certain status ... like "dev complete" or something. I create a rule to output a custom variable where I clean the sprint name:

{{sprint.name.substringBefore(" -")}}

The problem is, I'm getting an array of sprint names when I move something to "dev complete" and I only want the sprint name for the ACTIVE sprint, not all the sprints this one issue is a part of or has been a part of.

Any help?

3 answers

1 accepted

4 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.
January 7, 2021

Hi @Jason Anthony Montilla  -- Welcome to the Atlassian Community!

Yes, that sounds correct when an issue has been in multiple sprints which have closed over time.

One way to always have the current, open sprint is to add a custom field to issues, such as Current Sprint.  And then create an automation rule to set it when the sprint starts for the issues currently in scope. This gets trickier if you often add issues to a sprint after it begins, and would require an additional rule to manipulate the sprint values.

Best regards,

Bill

Jason Anthony Montilla January 8, 2021

Hi Bill, thanks for the answer! So I did discover something that may also be a possibility. I'm new to the conditional logic for smart values.... but I'm having a time trying to figure out how to loop through with a conditional statement. Here's what I came up with that doesn't work:

{{#sprint}}{{#if(not(isClosed))}}{{name}}{{/}}{{/}}

We start iterating the "sprint" list but we seem to lose the tie to it as soon as we break into the if. Any pointers there?

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.
January 8, 2021

Hi!  Well, the A4J is awesome...and...it does have some limitations.  ;^)

I believe that even if that syntax could work, it wouldn't for another reason: functions cannot work inside of an iterator structure (stuff with # / bracketing).  I submitted a separate defect/suggestion on that one.

What is the format of your sprint name?  Knowing that may help uncover how to parse this out.  For example, if your sprint names contain the date values, you can definitely use the max/min syntax to get info and maybe re-create the name:

{{issue.sprint.startDate.max}}

If that won't help, I suggest the work-around idea using the custom field and supporting rule.

Jason Anthony Montilla January 8, 2021

Sure, I can look at that workaround. I just want to see if there is another way to skin this.

 

The sprint names are basically:

Sprint 123 - Some random text

No dates, but using {{issue.sprint.startDate.max}} on an issue in multiple sprints... how would I pull just the name of the 1 with the max startDate?

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.
January 8, 2021

Hi again,

Okay, this works using a created variable and text parsing to return the "active" sprint.  Sprints have a state attribute which we can use.  I found the name of the attribute using this technique:

https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/

  • Use the action Create Variable, such as sprintStates with this value.  This forms a delimited list of sprint states and names.
~{{#sprint}}{{state}}:{{name}}~{{/}}
  • Grab the active sprint with this to parse with RegEx and remove the remainders.
{{sprintStates.match(".*(~active:.*~).*").remove("~active:").remove("~")}}

Note that if your sprint names use the ~ character or phrase "active:" you will need to tweak this a bit.

Also, this works for one issue at a time, so if you have a JQL set, you will need a branch to process each issue singly.

Best regards,

Bill

Like # people like this
Jason Anthony Montilla January 8, 2021

@Bill Sheboy That is pretty advanced and awesome stuff! I'll take a look and let you know. Thank you so much!

Like Bill Sheboy likes this
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.
January 8, 2021

You are welcome.  I'm glad there's an answer, as this question has appeared several times.  I used a similar technique to selectively add/remove items from components and labels.

Have a great weekend!

Like Jason Anthony Montilla likes this
Jason Anthony Montilla January 8, 2021

@Bill Sheboy Actually haha ... it didn't really do quite what I wanted but I think it may be the regex... here's the result:

RAV 58 - GR 2020closed:RAV 57 - Bugsclosed:RAV 55

You can see that Rav 58 (which is active) indeed shows up, but now I get the other 2 sprints this was a part of as well. I'm NOT a regex master.

 

Maybe I remove everything with .closed

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.
January 8, 2021

Please try logging the created variable to see what the result looks like.  That will help us figure out what RegEx to use.  Then post both values (full variable and after parsing).

If you use the two examples I provided, it should work unless my RegEx is wrong too.  ;^)

Jason Anthony Montilla January 8, 2021

BOOM ... it was really close:

{{sprintStates.match("~active:(.*?)~")}}

Thanks again Bill!

Like # people like this
Craig Cinder November 30, 2021

Hey, what actual values did you put in for automation? I have not been able to get the 

{{sprintStates.match(".*(~active:.*~).*").remove("~active:").remove("~")}} 

 function to work. 

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.
November 30, 2021

Hi @Craig Cinder -- Welcome to the Atlassian Community!

Did you note that we were constructing {{sprintStates}} as a created variable from the list of sprints, and that it is not built-in?  Please look earlier in the thread if you missed that.

Otherwise, how similar/different is your use case to what Jason was trying to do?

Kind regards,
Bill

Craig Cinder November 30, 2021

@Bill Sheboy Apologies, I missed the part about creating the variable. Did not realize that functionality existed and was banging my head trying to do this all day. 

I just tried your fix and it now works. Thank you so so much. 

Regards,
Craig

Like Bill Sheboy likes this
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.
November 30, 2021

Awesome!  I am glad to learn that helped you.

Like Craig Cinder likes this
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 21, 2023

UPDATE -- here is a much easier way I found to do this, with no variables:

Assuming the issues are in a lookup issues result, this can be done inline as follows:

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

How this works:

  • assuming your lookup issues has JQL to find the issues in the open sprint, such as with:
    • project = myProjectName AND sprint IN openSprints()
  • we only need to look at one issue, so we can use the first one
  • then we iterate over any of the sprints the issue has been assigned to
  • and using smart value, list filtering, only select the one(s) with the active state
  • finally returning just the name of the sprint

 

When there is just one issue being checked, the lookup parts can be dropped.

Like # people like this
Marcel Rossouw January 19, 2024

This helped me loads, always great results - thank you @Bill Sheboy 

Like Bill Sheboy likes this
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.
April 20, 2024

Greetings!

As an update to this solution approach, to handle the possibility of issues in multiple sprints, and which overlap for different stories.  The result produces a distinct list of sprints.

https://community.atlassian.com/t5/Jira-Software-questions/Struggling-to-parse-distinct-sprints-from-an-Automation-lookup/qaq-p/2624608#M926541

Kind regards,
Bill

4 votes
Srinath Narasimhan
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!
February 18, 2022

A Little late to the party, but this seems to work {{issue.sprint.last.name}}

Good information here - https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

moparsley October 26, 2022

Hi...Just want to note that your solution works like a charm even with DC/Server edition.

I was using {{issue.sprint.name.substringAfterLast(",")}} to no avail before coming across this thread.

 

context: I use it with automation rule to copy the last sprint value into a separate custom field to capture the actual sprint in which a story was completed.

Thanks 

-MP

Benjamin Dains June 21, 2023

@moparsley this was a great solution. It seems like last actually goes through the array and picks the last one. I was able to use it to get what I was looking for (even though my problem changed to finding if an issue was in the backlog or future or active sprint based off of iterating through the sprint array) and it was relatively easy to do compared to other stuff I've seen online.

list.last

The last element of a list.

{{issue.comments.last.author}}

 

0 votes
Hank January 7, 2022

Great solution, just what I needed, combined use with another custom field Completed in Sprint

Next I'd like to track "Number of Sprints Required", this is a metric we want to reduce.

Can someone suggest the RegEdit to count the number of Sprints in any given 

{{#sprint}}
Hank January 7, 2022

fount it, no regedit required: 

{{issue.sprint.size}}
YY哥
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 26, 2022

The lastest jira software cloud has supported to edit the Sprint to the active sprint of a specified board. It helps me with auto populate the bug's sprint when created.

Suggest an answer

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

Atlassian Community Events