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

Fetch Jira details in excel using python

Hi Guys,

I want fetch Jira details in excel using python based on some Projects and assignee

import jira.client
from jira.client import JIRA

options = {'server': 'https://xyz.com', 'verify':False}
jira = JIRA(options, basic_auth=('user', 'pasword'))
issue=jira.issue('DWO-23981')
print(issue)
print(issue.fields.description)

Could you please provide suggestion how to achieve that

 

Thanks 

 

 

 

 

2 answers

1 accepted

0 votes
Answer accepted
Shaun S Atlassian Team Apr 02, 2018

You can retrieve data from a search result using the "search_issues" method.  In the code below I receive results where the project key = ALPHA and the assignee is the username 'shaun'.

 

import jira.client
from jira.client import JIRA


jira_options={'server': 'http://jira.example.com'}
jira=JIRA(options=jira_options,basic_auth=('admin','password'))


issues_in_project = jira.search_issues('project=ALPHA AND assignee= shaun')

print issues_in_project

Thanks @Shaun S. But how can I get this details in xlsx format

I am getting number of tickets here from this.

[<JIRA Issue: key=u'DWO-23931', id=u'2216443'>, <JIRA Issue: key=u'DWO-23930', id=u'2216442'>, <JIRA Issue: key=u'DWO-23500', id=u'2095912'>, <JIRA Issue: key=u'DWO-23499', id=u'2095910'>]

 

 

I want these tickets in xlsx with all columns(Key,Summary,Status,Tag etc) like we do export all column from Jira in CSV format.

 

I hope you guys getting me.

Thanks,

Shaun S Atlassian Team Apr 04, 2018

Hi Himanshu,

 

Using the openpyxl library I was able to retrieve JIRA data and send the results to an xlxs spreadsheet.  The code below is a little rough, and I'm sure there's a more efficient way of writing the logic, but I thought I'd provide it in the event that it provides a good starting point for you. Hope that helps!

 

import jira.client
from jira.client import JIRA
from openpyxl import Workbook

jira_options={'server': 'http://example.com'}
jira=JIRA(options=jira_options,basic_auth=('admin','password'))


key_list = []
summary_list = []

#Add additional lists for fields here
#Example:
#description_list = []



issues_in_project = jira.search_issues('project=ALPHA AND assignee= admin')

for issue in issues_in_project:
key_list.append(issue.key)
summary_list.append(issue.fields.summary)

# Add additional fields returned here
# Example:
#. description_list.append(issue.fields.description)


wb = Workbook()
ws = wb.active
key_row = 1
summary_row = 1
#add additional "$FIELD_row = 1" entries here so the field results start at row 1
#Example:
#description_row = 1


start_column = 1



for key in key_list:
ws.cell(row=key_row, column=start_column).value = key
key_row += 1

for summary in summary_list:
ws.cell(row=summary_row, column=start_column+1).value = summary
summary_row += 1

# add additional fields here
#Example:
#for description in description_list:
# ws.cell(row=description_row, column=start_column+2).value = description
# description_row += 1

wb.save("jira-report.xlsx")
Like Darryl Dillman likes this

Hi..

I am not able to login jira using basic_auth method..

Getting errors like basic_auth is not defined.

Can anyone please help me to resolve this issue..

hello,

When i tried to fetch the comments from jira using this code i got a error as follows "Attribute Error: type object 'PropertyHolder' has no attribute 'comment'" can you please help on this

Is there a way to extract the Kanban boards into python?

Suggest an answer

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

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

344 views 1 3
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