Jira automation - how to 'promote' fixVersion to Parent matching children fixVersions with regexp

Michał March 7, 2024

Hey,

the trickiest automation I've seen till now ...

Could help?

  1. There is UberEpic issuetype which has linked Epics.
  2. Epics get fixVersions for quarters: DUN YYYY QX eg. "DUN 2024 Q1", "DUN 2024 Q2"
  3. Epics can have different fixVersions

I'm trying to fulfill this conditions:

If all linked Epics has the fixVersion for quarter set, add latest for UberEpic.

If any of the Epic has missing fixVersion for quarter, remove quarter from UberEpic. 

 

I got to situation where automation can

1. find find UberEpic

2. check if all linked Epics have fixVersion with pattern using 'related issue condition' with JQL: issueFunction in linkedIssuesOf('{{issue.key}} and issueLinkType = "Is a Parent of" ') AND issuetype = Epic

tricky part:

3. find latest quarter from all fixVersions in linked Epics? 

could I use 'Create Variable' with some magic in it?

 

that's my current state of rule:

rule.png

2 answers

1 vote
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 7, 2024

Hi @Michał 

Without seeing your entire rule and audit log details for context...

Have you tried using the max function on the list of fixVersion's date attributes to find the last one:

https://confluence.atlassian.com/automation/jira-smart-values-lists-993924868.html#Jirasmartvalueslists-list.maxlist.max

Kind regards,
Bill

Michał March 7, 2024

Hey @Bill Sheboy 

direction is very good. Is there a way to create a list of fixVersions from multiple issues? Or iterate every issue from jql :)?

Automation should find max of versions in all children of issue.

Thank you for your fast answer! I'll put schema tomorrow. 

 

Thank you

Michal

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

The answer depends upon what you want to do with the result, and which attributes of the version to access.  Seeing the specifics of your rule will help suggest more ideas.

 

With multiple versions assigned to each issue, this can get messy fast, and so you may need to experiment to learn how possible this scenario is.

For example, using list iterators, all of the fix versions spanning multiple issues could be concatenated into a single CSV list, split back into a list, reduced with distinct, and then filtered to one value with max on the release date attribute...storing that in a created variable.  Then that variable could be used to create another variable for a dynamic match() expression, which is finally used with in-line iteration to get the desired version.

I am using Jira Cloud, not Data Center, and so I cannot test how much of this is possible with that version of automation rules.

Michał March 8, 2024

I can see could have more advanced functions.

Here are pictures of hierarchy build on links.

and rule I got till now.

pattern.pngrule.png

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

I am unclear about that rule...regardless, assuming the issues are in a Lookup Issues result, here is how to find the maximum release date:

{{lookupIssues.fixVersions.releaseDate.join(",").replace("[","").replace("]","").split(",").distinct.toDate.max.jiraDate}}

How this works:

  • each issue contains zero-to-many fix versions, and so we need to use join() to merge their values
  • but...joining single values and arrays of values adds brackets, and so those must be removed with text functions
  • with the combined list of comma-separated values, we can use split() to convert back into a list
  • then use distinct to get one value per release included
  • finally converting to a date value to allow the max function to work

 

Michał March 12, 2024

Hey @Bill Sheboy ,

with lookup it was really easy to find related issues. And with your smart values snippet I was able to get list of fixVersions or it's dates. I already owe you a beer!

with this I get dates: {{lookupIssues.fixVersions.releaseDate.join(",").replace("[","").replace("]","").split(",").distinct}}

and with this I get names: {{lookupIssues.fixVersions.name.join(",").replace("[","").replace("]","").split(",").distinct}}

 

functions todate, max, or jiradate: 

toDate.max.jiraDate

does not give anything on output that could be printed to log.

when I'm trying to use update JSON (watch in other thread where you helped!) I get information it's not valid fixversion Name.

How would you get proper name from list having list of dates? Or handler to right version I could use further?

 

I can get list: maxVersion

Thu Jan 01 01:00:00 CET 2026, Wed Apr 01 02:00:00 CEST 2026, Wed Jul 01 02:00:00 CEST 2026, Wed Apr 01 02:00:00 CEST 2026

or version names: maxVersion DUN 2025 Q4, DUN 2026 Q1, DUN 2026 Q2, DUN 2025 Q3, DUN 2025 Q4

 

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

Short answer: I am stumped on this one, and I recommend working with your site admin to ping Atlassian Support to learn what they suggest, at this link https://support.atlassian.com/contact/#/

 

More information...

As I noted earlier, I am using Jira Cloud, and so there are likely differences with the behaviors you see in Data Center.  With that disclaimer out of the way...

Although we were able to find the max release date, I was not able to figure out a way to filter further to get at the version's id value, which is what is needed to set the fix version.  The reason (at least for Jira Cloud) is the release date values are date-only values without a time.  I could not find a way to format that value to match what releases appear to store in a full list of versions, such as:

Tue Feb 06 00:00:00 UTC 2024

The time component is the problem.  Conversion attempts always add a non-zero hour component, even when forced to the start of day.

And so without an ability to match the release date, the id cannot be found.

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

Update...this one was bugging me, so I kept looking at it to find an approach that works for Jira Cloud.  If it works for Data Center, awesome...although I expect the regular expression may need tuning.

 

Let's assume we have the maximum version date in a created variable, named varMaxReleaseDate.

We then create a dynamic, regular expression for use with the match() function.  That will be named varMatchExpression and contain this:

(id=.*releaseDate={{varMaxReleaseDate.toDate.format("EEE MMM dd").concat(" 00:00:00 ").concat(varMaxReleaseDate.toDate.format("zzz yyyy"))}})

That will match version records which have the date / time format I noted earlier by defaulting the time value.

Finally that can be used to get the single, version id value for selection:

{{lookupIssues.fixVersions.join("~~").replace("\n", " ").split("SmartVersionBean").match(varMatchExpression).match("id=(\d++)").distinct}}

 

The parts that originally stumped me were removing newlines from version descriptions and curly brackets cannot be used in a dynamic regular expression in rules.  The respective solutions were to replace the newlines and ignore the brackets by splitting on the text "SmartVersionBean".

Michał March 26, 2024

hey Bill,

thanks for you help. It's to complex for me due to lack of sorting list and getting version handler. I decided to do this automation with script outside Jira.

thank for your help and KUDO!

Michal

Like Bill Sheboy likes this
0 votes
Jason Chayer March 7, 2024

@Michał - unfortunately I do not have an answer to your question. However, curious where you got the issuetype UberEpic?

I would love to utilize this issuetype as linking Epics to a master project would be very beneficial.

Michał March 7, 2024

Hey @jas ,

in big Jira project of big Organization of name I shouldn't share publicly. UberEpis is just my 'code name'

This is just another Issuetype - you can create number of 'custom' issuetypes. It would better to use 'Jira portfolio' hierarchy with 'Initiatives' instead but I need some time to fix this and other config issues in this particular project.

Jason Chayer March 7, 2024

Ok, that makes sense. I finally ran across an article that mentioned "initiatives," I will take a look at that.

Thanks.

Like Michał likes this
Michał March 8, 2024

no problem,

it can be really challenging to tailor everything right and make it work smoothly :-) every company I join there is really much to let all work easier in more automated way

Suggest an answer

Log in or Sign up to answer