Jira Automation - Get the version with start/release date fit specific date

Michał August 5, 2024

Hi,

working on data center automation I try to get Version which start and release date fit specific date.

As data center lack fixVersion iteration I searched and find similar case:  

 

Solved: Jira Automation - Get the next unreleased version ... (atlassian.com)

and added condition to code: 

  {{#if (releaseDate.format("yyyyMMdd").isAfter(PDDdate))}}

but condition seems does not working, there are versions that are earlier and later than PDD so something should be returenr. 

Do you have any ide how to make this working or other solution to get one proper version od Data center automation?

 

{{#issue.project.versions}}

  {{#not(archived)}}

    {{#not(released)}}

      {{#name.startsWith("EIC 1.")}}

        {{#exists(releaseDate)}}

          {{#exists(startDate)}}

            {{#if (releaseDate.format("yyyyMMdd").isAfter(PDDdate))}}

              {{id}}-{{releaseDate.format("yyyyMMdd")}}

{{/}} {{/}} {{/}} {{/}} {{/}} {{/}} {{/}}

 

 Screenshot_5-8-2024_162857.jpeg

 

thanks

Michal

1 answer

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.
August 5, 2024

Hi @Michał 

Short answer: This is not possible using rules with version date filtering for an iterator.  If you explain how your variable PPDdate is defined, the community may offer other approaches, such as using JQL or calling the REST API to gather the versions for examination.

 

For more on why that type of filtering is not possible...

Once rule processing is inside of a smart value list iterator such as this:

{{#issue.project.versions}} ...inside the iterator... {{/}}

It cannot access any data which is not in the versions data.  And so your created variable PPDdate is not visible and thus evaluates to null.

 

If you carefully read that thread you linked to in your question, you will see the workaround for this limitation:

  • create a variable which expands all of your version data into a known, delimited format, for example named varVersionData and delimiting the records with "~~"
  • create a regular expression in another variable to search for the records, for example named varRegExSearch
  • use the inline form of iteration with the match() function to find your records, for example:
{{varVersionData.split("~~").match(varRegExSearch)}}
  • use text functions on the result to extract what is needed

However this will not help for your scenario as the match() cannot perform that type of date comparison.

 

Kind regards,
Bill

Michał August 6, 2024

thank you @Bill Sheboy ,

PDDdate is variable that containing date taken from customfiled.

When I updated comparison from using variable to direct customfield call I got some version that has no releaseDate as well does not comply previous conditions.

{{#if (releaseDate.isAfter({{issue.customfield_21970}}))}}

So I assume:

1. customfield can be accessed in iterator

2. #if statment does not take previous conditions so I can't use one iterator to select correct version. 

I believe I should follow rather Boldizsár Vermes solution. So moving step back. 

I have a list of versions that meet few conditions.

How can I select one that has earliest 'releaseDate' after date in customfield_21970?

 

 

{{#issue.project.versions}}
{{#not(archived)}}
{{#not(released)}}
{{#name.startsWith("EIC 1.")}}
{{#exists(releaseDate)}}
{{#exists(startDate)}}
{{#if (releaseDate.isAfter({{issue.customfield_21970}}))}} //- this return one version 
{{id}}-{{releaseDate}}

 

automerr.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.
August 6, 2024

As I already described, the custom field is not "visible" inside of the iterator on versions.  Only data from versions (and lower) is visible.

 

I do not believe a greater than date from a custom field search of version, release dates is possible with an Atlassian Automation rule with Jira Data Center.

 

If you know the exact release date to match, that can be found.

If the date you want is the maximum (or minimum) from the versions, that can be found.  (This could be refined if rather than using {{issue.project.versions}} a call is made to the the REST API to gather the unreleased versions, in release date order.)

 

Like Stefan Salzl likes this

Suggest an answer

Log in or Sign up to answer