Forums

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

Accessing a Sprint name inline in JIRA automation's Email Step using smart variables

David Alexander December 21, 2023

Hi,

I have a LookupIssues step in my automation rule. I want to extract, from the first (or any) issue in that LookupIssues, the latest (and only Open / Active) Sprint.

I specifically want the name of the Sprint, rather than the end date, start date etc. The names are formatted in a simple manner, e.g. "Sprint 1" "Sprint 2" etc.

Issues in this LookupIssues JQL only ever have one Open Sprint in their Sprint field, but may have many closed Sprints in their Sprint field.

I have tried variations such as;

{{lookupIssues.get(0).sprint.last.name}}; this correctly produces the last in the list

{{lookupIssues.sprint.get(0).name}}; this correctly produces the first in the list

and many other variations that produced nothing at all. 

The issue with the two methods above is that they produce the first and last in the list, which is actually unordered (for some reason, despite the sprints never overlapping in time & date, and always being Closed and Opened sequentially one after another). So instead of retrieving the latest (and only Open) Sprint name (e.g. Sprint 12), I retrieve what looks like an arbitrary Sprint name (e.g. Sprint 4). 

I have consulted this thread, specifically the Create Variable solution, then attempted to use variations of sprintStates.match. I feel as though this could get somewhere, I had a few variations resulting in [] truncated characters.  

Has anyone made progress on fishing out the Sprint name this way, or another way, after encountering the ordering problem / not being able to use .last or .get(0), as mentioned above? 

1 answer

1 accepted

2 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.
December 21, 2023

Hi @David Alexander 

To do that inline, please try this expression with your lookup issues:

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

Kind regards,
Bill

David Alexander December 21, 2023

Bill, I learn so much from you!

I didn't think that state was a property that could be natively accessed in these expressions. That solves the issue perfectly. Thank you and happy holidays :)

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.
December 21, 2023

Glad to help, and thanks for that link to the older post; I updated my answer to that one to simplify the approach in case people find it there.

Happy holidays to you too!

Like David Alexander likes this

Suggest an answer

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

Atlassian Community Events