Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,323,862
Community Members
 
Community Events
168
Community Groups

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 

 

 

 

 

3 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 # people like 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..

Like # people like this

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

Hi,

I am not getting accurate mapping of jira and iits related fields.

Can anyone help me in this?

Thanks.

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

@Shaun S : how to get headers in excel in your above code?

Suggest an answer

Log in or Sign up to answer