Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to fetch release date of a version using groovy script

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

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.

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

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) ?

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.

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 ""

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

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

return date

Hi Petar,

Could you please help? I am stuck.

Thanks,

Nishant

 

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?

 

Version-ReleaseDate.png

 

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,243 views 12 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you