Hi Guys,
Could you please help to get Tag and Sprint value for particular issue
import jira.client
from jira.client import JIRA
options = {'server': 'https://example.com', 'verify':False}
jira = JIRA(options, basic_auth=('user', 'password'))
issues_in_project = jira.search_issues('project=11372 AND SPRINT not in closedSprints() AND sprint not in futureSprints()')
for value in issues_in_project:
print value.key , value.fields.summary , value.fields.assignee , value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, value.fields.duedate, value.fields.labels,value.fields.tag
While running the python script , I got error
DWD-9933 Loading and Validating Products username username 2018-04-02T23:27:07.000-0700 None 2018-04-06 [u'DW-Products']
Traceback (most recent call last):
File "jira_test.py", line 23, in <module>
print value.key , value.fields.summary , value.fields.assignee , value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, value.fields.duedate, value.fields.labels,value.fields.tag
AttributeError: type object 'PropertyHolder' has no attribute 'tag'
Please have a look once and help me to achieve this
Thanks,
Hi Himansu,
Boy this was a tough one. The sprint data associated with an issue is stored in the custom field "Sprint". By calling "value.fields.customfield_<id>" I was able to get that data, but it's a nasty string containing sprint data other than the sprint name:
[u'com.atlassian.greenhopper.service.sprint.Sprint@5d9e64fb[id=1,rapidViewId=1,state=ACTIVE,name=Sample Sprint 2,startDate=2017-06-04T05:32:50.263Z,endDate=2017-06-18T05:52:50.263Z,completeDate=<null>,sequence=1,goal=<null>]']
With a little regex magic I was able to filter out the unnecessary data and only return the name. Here's the code I used to achieve this. You'll want to replace the text "customfield_10004" with the customfield<id> that corresponds to the "Rank" field in your environment.
issues_in_project = jira.search_issues('project=11372 AND SPRINT not in closedSprints() AND sprint not in futureSprints()')
for value in issues_in_project:
for value in issues_in_project:
print value.key , value.fields.summary , value.fields.assignee , value.fields.reporter ,value.fields.updated ,value.fields.resolutiondate, value.fields.duedate, value.fields.labels
for sprint in value.fields.customfield_10004:
sprint_name = re.findall(r"name=[^,]*", str(value.fields.customfield_10004[0]))
print sprint_name
Hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Happy I could help! I also forgot to mention that you'll need to import the regex library for the call to work.
import re
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ended up with :
activeSprint = re.findall(r"name=[^,]*", [str(sprint) for sprint in a.fields.customfield_10004][-1])[0].split("=")[1]
;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you guys so much. I have been wasting hours of my life to get to this brilliant solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad it was of help ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.