How to get Version from issue?

Hi All,

How to get version from and also from version to release date.The fallowing code i am useing

But I am not getting please any body have on this

GenericValue issueGv = issue.getProject();

<font style="font-size: x-small;" size="2"></font>

List versions =

<font style="font-size: x-small;" size="2"></font>

versionManager<u style="text-decoration: underline;">.getVersions(issueGv)</u>;

2 answers

List&lt;Version&gt; versions = componentManager.getVersionManager().getVersions(issue.getProjectObject().getId())

I have used but i am getting

InvocationException and NullpointerException while getting versions

What language are you using? I'm just trying to give you a pointer to the correct APIs.. first() is not valid in java. Make sure you've checked for nulls etc and have initialised componentManager.

Java only.I am trying to get earliest date from the vesions.Suppose fix version is multiple choice filed

So need get earleist date in those version(I am useing calculated custome plug-in)and displaying the date

ok how to initialise the componentManager I am new to this JIRA API

ComponentManager componentManager = ComponentManager.getInstance();

i am ComponentManager componentManager = ComponentManager.getInstance();

is it ok? and How to get release date from version list in java?

suppose i have added version v1.1 and v1.2

v1.1 release date is 2/7/2010

v1.2 release date is 2/7/2011

So i need to get v1.2 release date(2/7/2011) from the issue

This date i need show in the edit issue like filed "Sloution Available Date"

everytime the ticket is edited based on the earliest date of the field "fix version".

Yes your component manager line is correct. Fix version(s) is a multiplie choice field, so I'm assuming you're using fixversions as opposed to a custom field. Then you want the java moral equivalent of:

Date lowestRelDate = issue.getFixVersions().min {Version version -&gt; version.releaseDate}?.releaseDate

That is, get all the fix versions from the issue. Find the Version with the lowest release date, and get its release date. I can't write that in java for you, too boring. Maybe someone else will.

I get it already. Without writing it for you I don't see what else I can say.

ThankYou so much I am getting release date from version.

And in getValueFromIssue methos it is return the release date Then How to set this date as custome filed

while edting the issue.

Oh you mean this question

If it's a computed field then it does it for you when the issue is updated. To set the value on existing issues, re-index.

Jira 4.3, Python 2.7 environment.

Fetching the version (in which fixed) from an issue: use REST API.

import json
from restkit import Resource, BasicAuth, request

#... authentication

# Convert the text in the reply into a Python dictionary
issue = json.loads(response.body_string())


fields = issue['fields']
for field_name in fields:
field_object = fields[field_name]


elif field_name in ["fixVersions"]:
fDict = getValueDict(field_object['value'])
for fkey,fval in fDict.items():
if fkey in ["name"]:
iDict['targetSW'] = fval
iDict['targetSW'] = 'unset'

Setting the version (in which found) when creating an issue: REST is not available until Jira 5.0, must use suds.

Using the Python suds jira-cli-4.4, thanks to Matt Doar, modified it, to be able to set the Affects Version/s, by version name NOT id, so the flag used is -r "Affects Version/s:99.9.1" for version named '99.9.1'

Retrieves the version names for the project using getVersions.

Gets the id for the version name. Uses the existing API to set the version for creating the issue.

# Get the project versions
jira_env['versionnames'] = soap.service.getVersions(auth, options.project)
except Exception, e:
jira_env['versionnames'] = [{'id':-1, 'name':'unavailable'}]
verf_choices = getChoicesStr(jira_env['versionnames'])

# Translate affectsVersions names to id
affectsVersions = []
if options.affectsversions:
nameV, valV = options.affectsversions.split(':')
avId = 'unknown'
for i,v in enumerate(jira_env['versionnames']):
if v['name'] == valV:
avId = v['id']

if avId == "unknown":
logger.error("Field version '%s' not found in %s" % (valV, verf_choices))
return 0

version = {'id': avId.strip()}

You could code for fixVersions in the same way to be able to specify the name instead of the id.

Glad you found the Python CLI useful!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,686 views 3 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you