Forums

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

Export Issues with Sprint name via python API

Ian McQuillen September 7, 2023

I've managed to pull in a list of issues, and found that apparently Sprint is stored as customfield_10003 in our Jira instance. I want to manipulate the data in python dataframes, push it to reporting software, whatever.

But I'm running into problems trying to get the sprint names into a useful format in a list or dataframe. I've been looking all over but I can't seem to find a solution that works.

 

Code:

from jira import JIRA

jiraOptions = {'server': "https://my_domain.atlassian.net"}

jira = JIRA(options=jiraOptions, basic_auth=("username", "auth_token"))
issues_in_project = jira.search_issues('project IN (proj_name)')
for value in issues_in_project:
      print(value.fields.customfield_10003)
Returns a list like: 
None
None
None
[<jira.resources.PropertyHolder object at 0x0000016A46C49E70>]
[<jira.resources.PropertyHolder object at 0x0000016A46C4A8F0>]
[<jira.resources.PropertyHolder object at 0x0000016A46C4B1F0>]
None
None  
The "none" entries prevent me from calling value.fields.customfield_10003.name, with the following error:
"AttributeError: 'NoneType' object has no attribute 'name'"  
I've found a solution like this:
for sprint in value.fields.customfield_10003:
     sprint_name = re.findall(r"name=[^,]*", str(value.fields.customfield_10003[0]))
      print(sprint_name)  
But again, same error as I listed above.  
So, the main question: what is the best way to export  Issues data including Sprint?

2 answers

0 votes
ELFAPP Technologies
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 8, 2023

Hi

You can export the field Sprint into CSV, read the CSV file, filter all the empty cells which are not needed and populate the sprint names in your data frame required for your reporting software. This article shows how to export issues from Jira via the API.

Ian McQuillen September 11, 2023

I see, yeah one method or the other as long as I am getting JQL results into python it's not too important the exact method. Thanks!

One remaining question I have is with populating the sprint names. I realized that I was being a fool and could just filter out the empty sprint fields in JQL, so I did so. But when I try to return something using the following (same as above) 


for value in issues_in_project:
print(value.key, value.fields.summary, value.fields.assignee , value.fields.reporter,
value.fields.resolutiondate, value.fields.duedate, value.fields.labels, value.fields.customfield_10003.name)
I get the following error:
File "<ipython-input-9-4a9e020d6c2d>", line 4, in <module>
value.fields.resolutiondate, value.fields.duedate, value.fields.labels, value.fields.customfield_10003.name)
AttributeError: 'list' object has no attribute 'name'
  
So actually, it appears that I can't just populate the sprint names so easily after solving the "None" issue.
Are you aware of any resources aimed more at that part of the problem? There are several solutions from a few years ago, but I think the response for the sprint object has changed since then and the solution above using re library no longer makes sense.
ELFAPP Technologies
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 25, 2023

I would suggest that you get a export of issues from Jira as that would easily help you identify issues with sprint name or not, then you can decide to omit the ones that are empty versus the ones that has a value and put that data into a list as intended. I think querying each issues via API concurrently to find out the sprint name isn't efficient. And to your question, I believe you could look into the documentation of the python library you're using to understand if you can use dot notation that way to get the value from custom fields.

0 votes
Ian McQuillen September 7, 2023

The formatting is kind of bad, I tried to add some white space but it didn't save that way so oh well.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events