How to extract the current sprint from issue.sprint.name.substring

adrimars March 19, 2024

Hi there,

In my automation, I want to validate a story is assigned to the right sprint, for the right team.

We have naming conventions, so:

Team  LSUS1

would be sprint :  FY24Q3 LSUS1 S9 

....as an example

So I have built automation to use an IF for :  {{issue.sprint.name.substring(7,12)}}  "does not equal"  LSUS1

The problem I'm hitting, is that if a story has been in multiple sprints, then I might get an array of results coming back:

In my debug I print out what that produces:

Debug: LSUS1, LSUS1, LSUS1, LSUS1, LSUS1 is not LSUS1

So a string comparison there fails.

 

I could switch to "does not contain", but that's problematic because if the history shows that ID just once, then the rule would not trigger.

I need to get to just "current sprint" somehow.   Any clues ?

4 answers

0 votes
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 25, 2024

Hi @adrimars 

I recommend trying this with a regular expression to compare the team name(s) to the sprint name.  When there are multiple teams to check, those could be iterated over using an advanced branch.

You also seem to be describing this for the "current sprint".  What do you mean by that: the active sprint, the next future sprint, something else?

Regardless, how would this scenario even happen?  During sprint planning, wouldn't the team recognize not to pull in work which is not their own?  Same situation for any change to sprint scope once the sprint starts.

Kind regards,
Bill

adrimars March 25, 2024

Hi Bill,

Yes - "Active Sprint"..  I can't find a way of finding that in Jira.  The only field I've seen is issue.sprint.name which can contain several values, one value, or nothing at all (backlog).  It can even contain just historic (if moved to backlog but with a history).

Team mixing can happen for multiple reasons though:

- In scrum of scums stories can be passed between teams if its decided that other team should take that story.

- Simple mistakes.. the Jira UI doesn't help us here because its very easy for someone to accidentially choose either the wrong sprint, or the wrong team.  I've added automation to try and make sure that Assignee and Team are in sync.  Now I have to figure out Team <> Sprint.

If there was one field that was either Active Sprint - or blank (backlog), that would solve my problem.

 

Thanks for listing Advanced Branch - I'm still learning the Automation features one bit at a time.  I know the If/Else technique isn't great, right now though I just need to get the basics running, then I can optimize/improve.

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 25, 2024

Thanks for the additional scenario information.

 

When an issue has multiple sprint values in the field, you may filter on the state attribute to find the active one, using conditional logic.  For example, this will produce the name for that sprint, or nothing is there is no active sprint assigned to the issue:

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

 

0 votes
Kalyan Sattaluri
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 19, 2024

Hello @adrimars 

Can you clarify what is your actual requirement? I gathered that you want to check an issue sprint value, but..

Do you have the latest Sprint name available for you to check against?

Unless we know what your requirement is, tough to suggest because this is a common ask with challenging solution.

Please see @Bill Sheboy 's suggestion. If your sprint names are sortable, do a {{issue.sprint.name.max}} , else find the largest Sprint ID and do a web request call to get the sprint name.

https://community.atlassian.com/t5/Jira-Software-questions/How-to-get-name-of-newest-sprint-in-ticket/qaq-p/2023663

0 votes
adrimars March 19, 2024

Screenshot 2024-03-19 124955.png

 

Yep sure..  I tried to copy/paste it in here earlier but that doesn't seem to work (odd that Jira itself can do that but the forums here can't ...)

0 votes
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 19, 2024

Hi @adrimars 

Can you please share a screenshot of the rule?  This will help us understand the broader context of what you're doing with the rule so we can provide the best answer.

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 19, 2024

Sorry - I meant the full rule with all components.  Just trying to get a better sense of your end goal.

adrimars March 25, 2024

Hi Mark,

Its too long really for a screenshot.

But basically:

- Limit scope - there's an IF that limits which Jiras fall into scope, to make sure I don't stomp my automation on others who share the Project

- Run the test 4 times, comparing 4 sets of teams to sprints.

For each test, its basically extracting the text out of the Sprint Name.  If it doesn't match the test, then it'll clear the sprint value, send email and make a comment.

It works, when there's just one sprint value returned.  But for stories that have passed through several sprints, I get several results.  The substring works over all the results.. the problem is I don't know which might be the "current value".

I face this problem in other areas of Jira, where Jira doesn't seem to have a "now" field around sprint value (I don't need the history).   But in this example, I'm getting an array.

Lets take three teams:  LSUS1, LSUS2 and LSAP1

If a story transitions LSUS1 S1 -> LSUS2 S1 -> LSAP1 S2

Then in that data, LSAP S2 is the last sprint..  I think Jira only tags the history if its an active-sprint. Meaning if I'm currently in S1, then LSAP1 S2 is a future sprint.

That basically makes figuring out "Now sprint" really hard, because if I try to Sort, then LSAP1 goes to the top.  But if there was an LSUS S3.. that would be the bottom.

I just don't know how to get to "now" in sprint terms as a single return.

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2024

I appreciate the additional context, but I'm still struggling to understand your end goal.  Are you trying to build an automation rule that reviews all issues in active sprints to validate they are assigned to the correct team and if not, move the issue to the appropriate sprint?

adrimars March 25, 2024

Pretty much that yes Mark.


Pseudo code:

if Team = LSUS1

  -  Check if the Sprint value contains LSUS1

  -  If not :  Clear the sprint value as its invalid

 

At this stage I'm not trying to set to the correct sprint. Maybe one day.. but for now I'd be happy just moving the story to backlog with the notices that it needs to be looked at.

The problem in the test only comes when we get multiple results for the sprint value.  "LSUS1, LSUS1, LSUS1" does not equal "LSUS1" if that story has 3 sprints history.

Here's a screenshot of one of the Ifs,  there's 3 more for the other teams in play, but all the same logic, just values change.

 

Screenshot 2024-03-25 134705.png

Suggest an answer

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

Atlassian Community Events