Skip to content

Instantly share code, notes, and snippets.

@teopost
Created August 19, 2019 13:14
Show Gist options
  • Save teopost/f55619fdba0dfa2093879aa40817bfb6 to your computer and use it in GitHub Desktop.
Save teopost/f55619fdba0dfa2093879aa40817bfb6 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import csv
from jira import JIRA
options = {'server': 'https://server.atlassian.net'}
jira = JIRA(options, basic_auth=('s.teodorani@acme.it', 'xxxxxx'))
size = 1000
initial = 0
JSQL='''
project in ("RayBan Platform") AND ("Release Number" is EMPTY OR "Release Number" = "Production Support") AND "Impacted Environment" in (PROD, ALL, "PROD (STAGE)", UAT, SIT) AND Company = "Tecla WCS" AND (labels not in (InfraAdhoc, InfraCR) OR labels is EMPTY) AND ("IT Service Area" not in (ALERT) OR "IT Service Area" is EMPTY) AND (status was "In Progress" during (startOfDay(-1d), startOfDay()) OR status changed during (startOfDay(-1d), startOfDay())) AND (developer in membersOf(tecla-users) OR assignee in membersOf(tecla-users) OR assignee = FGastaldo) AND "Planning Date" >= 2018-01-01 ORDER BY "Planning Date", Developer
'''
with open('some.csv', 'wb') as f:
writer = csv.writer(f)
header = [
'ISSUE_KEY',
'ISSUE_ID',
'ISSUE_TYPE',
'PRIORITY',
'STATUS',
'SUMMARY',
'STORE_LOCALE',
'ASSIGNEE',
'REPORTER',
'UPDATED',
'PLANNING_DATE',
'UPDATED',
'PLANNING_DATE',
'DEVELOPER',
'RELEASE_NUMBER'
]
writer.writerow(header)
while True:
start= initial*size
issues = jira.search_issues(JSQL, start,size)
#issues = jira.search_issues(JSQL)
if len(issues) == 0:
break
initial += 1
for issue in issues:
try:
store=issue.fields.customfield_10312[0].value
except (NameError, TypeError):
store=u''
print 'issue key:',issue.key
print 'issue id:',issue.id
print 'Issue Type=',issue.fields.issuetype.name
print 'Priority=',issue.fields.priority.name
print 'Status=',issue.fields.status.name
print 'Summary=',issue.fields.summary
print 'Store locale=', store # store locale campo custom
print 'Assignee=',issue.fields.assignee.displayName
print 'Reporter=',issue.fields.reporter.displayName
print 'Updated=',issue.fields.updated
print 'Planning Date=',issue.fields.customfield_10318 # campo custom Plamnning Date
print 'Developer=',issue.fields.customfield_10804 # campo Developer
print 'Release number=',issue.fields.customfield_10700 # campo custom release number
print '=============================================='
row = [
issue.key,
issue.id,
issue.fields.issuetype.name,
issue.fields.priority.name,
issue.fields.status.name,
issue.fields.summary,
store,
issue.fields.assignee.displayName,
issue.fields.reporter.displayName,
issue.fields.updated,
issue.fields.customfield_10318,
issue.fields.customfield_10804,
issue.fields.customfield_10700
]
print writer.writerow([unicode(s).encode("utf-8") for s in row])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment