How to fetch release date of a version using groovy script

Nishant Kansal September 5, 2016

Hi,

My requirement is to fetch the release date of a version for an issue using groovy.

I am able to get version name (08.00.10D). Next, I tried couple of ways using "getFixVersionsFor" and "version.getReleaseDate()" method for fetching the release date, however, couldn't succeed.

Version-ReleaseDate.png

Please help.

Nishant

8 answers

1 accepted

1 vote
Answer accepted
Petar Petrov (Appfire)
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.
September 7, 2016

So you have a custom field which holds a version (or a set of versions). Using issue.fixVersions will not work, because this returns the value of the system "Fix Versions" field, which you are not using - you have a custom field instead.

What you need to do is retrieve the value of the custom field and then call one of the methods on VersionManager to get the Version object. You can then call getReleaseDate() on that object. Which VersionManager method to call depends on what is stored as value of the custom field - there are appropriate methods for finding versions by id or by name.

Nishant Kansal September 7, 2016

Many thanks Petar. Your directions helped me in resolving the same.

deepu September 18, 2018

Hi petrov, is there a way we can use script runner for jira to disbale release if all the issues in the version are not resolved (done/closed) ?

0 votes
Nishant Kansal September 7, 2016

In the above image, we are creating versions with a specific name and release date like we do it in standard way in JIRA. Next, issues in the projects are tagged to particular versions to track their release.

All, I need is to return the release date corresponding to the attached version for an issue to a custom field.

Please do let me know, if any more information is required.

0 votes
Nishant Kansal September 7, 2016

 

Version-ReleaseDate.png

 

0 votes
Petar Petrov (Appfire)
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.
September 7, 2016

Let me get this straight - you have a custom field which holds a version? And you are not using the Fix Version system field for that?

0 votes
Nishant Kansal September 7, 2016

Hi Petar,

Could you please help? I am stuck.

Thanks,

Nishant

 

0 votes
Nishant Kansal September 5, 2016

What is wrong in this? It is returning "[]"

def date = new Date()
date = issue.fixVersions*.releaseDate

return date

0 votes
Nishant Kansal September 5, 2016

Please find below the script...The section "HELP NEEDED HERE" is where I have to return the release date of the corresponding patch version. 

//Variable Declarations:START
def issue //To hold issue key-id
def customPatch//To hold custom field name as "Patch Version"
def patchValue //To store corresponding patch version value for an issue
//Variable Declarations:END
issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("ABCD")
//Fetching patch version:START
customPatch = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12345)
//Fetching patch version:END
//Checking if patch version field is not null and fetching patch version value:START
if(customPatch != null) {
    patchValue = (String) issue.getCustomFieldValue(customPatch);
    }
//Checking if patch version field is not null and fetching patch version value:END


"HELP NEEDED HERE...NEED TO RETURN RELEASE DATE OF PATCH VERSION stored in "patchValue ""
0 votes
Petar Petrov (Appfire)
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.
September 5, 2016

Post you whole groovy script so we can answer your question. Generally the method you are looking for is Version.getReleaseDate() but since you say this does not work for you, there may be something else wrong.

Suggest an answer

Log in or Sign up to answer