-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjira-ticket-summary
executable file
·51 lines (41 loc) · 1.38 KB
/
jira-ticket-summary
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
#!/usr/bin/python
import re
import smtplib
import time
from jira.client import JIRA
FROM = 'JIRA Ticket Summary <[email protected]>'
RECIPIENTS = (
'Tim Cartwright <[email protected]>',
'Brian Lin <[email protected]>',
'Mat Selmeci <[email protected]>',
)
PROJECT = 'SOFTWARE'
STATUSES = ('Open',
'Selected for Development',
'In Progress',
'Development Complete',
'Ready for Testing',
'Ready for Release')
URL = 'https://opensciencegrid.atlassian.net'
jira = JIRA(URL)
# Adapted from Mat's aggregator/emailer.py script
def mail_message(subject, message, recipients):
payload = ( 'Subject: %s\r\n' % subject
+ 'From: %s\r\n' % FROM
+ 'To: %s\r\n' % ', '.join(recipients)
+ '\r\n'
+ message )
smtp = smtplib.SMTP('localhost')
smtp.sendmail(FROM, recipients, payload)
smtp.quit()
def project_status_total(project, status):
search = 'project = {} AND status = "{}"'.format(project, status)
return jira.search_issues(search, maxResults=0).total
text = 'JIRA Software tickets:\n\n'
for status in STATUSES:
count = project_status_total(PROJECT, status)
text += ' * %s: %s ()\n' % (status, count)
text += '\n'
text += 'Completed at %s\n' % (time.strftime('%Y-%m-%d %H:%M'))
subject = 'JIRA ticket summary'
mail_message(subject, text, RECIPIENTS)