-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjira_sprint_exporter.py
92 lines (61 loc) · 2.6 KB
/
jira_sprint_exporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on May 30, 2013
@author: jschaul
install dependencies via "sudo pip install pycrypto jira-python"
(see : http://jira-python.readthedocs.org/en/latest/ )
'''
#change this value accordingly:
SERVER = 'https://<your-name>.atlassian.net'
import datetime
from jira.client import JIRA
import argparse
HOURSECONDS = 3600
print datetime.datetime.now()
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--password', help="jira password")
parser.add_argument('-u', '--username', help="jira username")
parser.add_argument('-s', '--sprintname', help="full name of the sprint")
args = parser.parse_args()
AUTH = (args.username, args.password)
def main():
print "Starting..."
jira = JIRA(options={'server': SERVER}, basic_auth=AUTH) # a username/password tuple
sprint = jira.search_issues('sprint = "'+args.sprintname+'"')
with open('{}.txt'.format(args.sprintname), 'wb') as f:
parentList = []
for i in sprint:
issue = jira.issue(i.key)
try:
parentList.append(issue.fields.parent.key)
except:
pass
f.write(issue.key.encode('utf8') + '\n')
f.write(issue.fields.summary.encode('utf8') + '\n')
f.write('\n')
if issue.fields.description:
f.write(issue.fields.description.encode('utf8').strip().replace("\t", "").replace("\r", "").replace("\n\n", "\n") + '\n\n')
f.write(getstorypoints(issue))
f.write('\n'.join(["" for i in range(5)]))
parents = set(parentList)
f.write("--------------------")
for i in parents:
issue = jira.issue(i)
f.write(issue.key.encode('utf8') + '\n')
f.write(issue.fields.summary.encode('utf8') + '\n')
f.write('\n')
if issue.fields.description:
f.write(issue.fields.description.encode('utf8').strip().replace("\t", "").replace("\r", "").replace("\n\n", "\n") + '\n\n')
f.write(getstorypoints(issue))
f.write('\n'.join(["" for i in range(5)]))
print 'writing complete'
def getstorypoints(issue):
try:
return "Estimate: " + str(int(issue.raw['fields']['customfield_10004']))
except:
return "(estimate?)"
#return str({"estimate":issue.raw['fields']['customfield_10004'], 'all':issue.raw['fields'], 'remaining':issue.raw['fields']['aggregatetimeestimate'], 'spent':issue.raw['fields']['aggregatetimespent'], 'estimate':issue.raw['fields']['aggregatetimeoriginalestimate']})
if __name__ == '__main__':
# all()
main()