Forums

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

Who to get the choosen value of fix version/s

Manuel Herzberger
July 10, 2018

Hello

we are using the jira field "fix version/s" in our configuration.

Based on the the dates from the releases, we want to calculate the CW of the given date.

This works fine, when we use a custom field to choose the release, but with the fix version/s we do not know how to get the value from the field.

 

I hope someone has an idea for that issue.

2 answers

1 accepted

0 votes
Answer accepted
Alexey Matveev
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 Champions.
July 10, 2018

Hello,

You can get a value from Fix Versions like this:

issue.getFixVersions()
Manuel Herzberger
July 10, 2018

Hi,

issue.getFixVersions()

returns  a "Collection" and out of this collection I don't know which is the selected value.

Alexey Matveev
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 Champions.
July 10, 2018

It returns you the collection of selected FixVersions. You can select multiple fix versions in this field.

Manuel Herzberger
July 11, 2018

Hi

I try it like theese:

def list = issue.getFixVersions();

def Date2 = list[0];
print Date2.getReleaseDate();
def test = new Date(Date2.getReleaseDate().getTime());
return test;

The date of the release is "23/Apr/19" but I get this "Mon Apr 22 00:00:00 CEST 2019"

Alexey Matveev
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 Champions.
July 11, 2018

You need to format the date like this:

import java.text.SimpleDateFormat

def list = issue.getFixVersions();

def Date2 = list[0];
print Date2.getReleaseDate();
def test = new Date(Date2.getReleaseDate().getTime());

SimpleDateFormat dt = new SimpleDateFormat("yyyyy-mm-dd hh:mm:ss");
return dt.parse(test);
 

Manuel Herzberger
July 11, 2018

This looks good, but the dt.parse(test) does not work. The MEthod is not able to parse Date.

Maybe there is another way?

Alexey Matveev
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 Champions.
July 11, 2018

Try this one:

import java.text.SimpleDateFormat

def list = issue.getFixVersions();

def Date2 = list[0];
print Date2.getReleaseDate();
def test = new Date(Date2.getReleaseDate().getTime());

SimpleDateFormat dt = new SimpleDateFormat("yyyyy-mm-dd hh:mm:ss");
return dt.format(test);
 
Manuel Herzberger
July 11, 2018

Thx it works.

Alexey Matveev
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 Champions.
July 11, 2018

If my answer helped you, kindly accept my answer.

0 votes
Janne Jaula
August 26, 2020

With JCMF misc custom fields I ended up with a solution like this, taking into account there might be multiple fixversions in each issue.

Last release date (null and thus field not shown if empty)

def version = issue.getFixVersions();
def releasedates = [];
version.eachWithIndex { it, i -> // `it` is the current element, while `i` is the index
releasedates.add(it.getReleaseDate().format("yyyy-MM-dd"))
}
return releasedates.max();

First start date (null and thus field not shown if empty)

def version = issue.getFixVersions();
def startdates = [];
version.eachWithIndex { it, i -> // `it` is the current element, while `i` is the index
startdates.add(it.getStartDate().format("yyyy-MM-dd"))
}
return startdates.min();

Should also be easy enough to modify to support datetimefield type if needed, we just needed plain datestamp here.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events