8 __doc__ =
"Interface with CERN JIRA instance."
9 __author__ =
"Edward Moyse"
15 import PyUtils.acmdlib
as acmdlib
21 base_url =
"https://its.cern.ch/jira/rest/api/2/"
22 url = base_url+querystring
24 r = requests.get(url, cookies=cookies)
25 if r.status_code != 200:
26 if r.status_code == 401:
27 print (
'Authorisation has failed. Have you got a valid SSO cookie? If not, re-run "cern-get-sso-cookie -u https://its.cern.ch/jira/loginCern.jsp -o jira.txt" ')
29 print (
"Something has gone wrong! The response is: ", r.text)
33 response = json.loads(r.text)
36 @acmdlib.command(name=
'jira.issues')
37 @acmdlib.argument(
'-c',
'--cookies',
40 help=
'the CERN SSO cookies file')
41 @acmdlib.argument(
'-r',
'--release',
43 help=
'Limit the response to the specified release')
44 @acmdlib.argument(
'-m',
'--myissues',
48 help=
'Limit the response your own issues')
49 @acmdlib.argument(
'-q',
'--query',
51 help=
'Use the specified query string i.e. "search?jql=assignee=currentUser()+and+resolution=Unresolved"')
52 @acmdlib.argument(
'-s',
'--status',
54 help=
'Limit the search to issues with this status, e.g. "Open"')
57 """Interface to the CERN JIRA instance"""
61 cookiesFile =
open(args.cookies,
'r')
63 for line
in cookiesFile:
65 if 'JSESSIONID' in line:
66 cookies[
'JSESSIONID'] = text[-1]
67 if 'atlassian.xsrf.token' in line:
68 cookies[
'atlassian.xsrf.token'] = text[-1]
70 print (
"Problems opening cookie file at ", args.cookies)
75 print (
"Will use the following search string: ",args.query)
76 querystring = args.query
78 querystring =
"search?jql=resolution=Unresolved"
80 querystring +=
"+AND+assignee=currentUser()"
82 querystring +=
"+AND+affectedVersion="+args.release
84 querystring +=
"+AND+status="+args.status
86 response =
queryJira(querystring, cookies)
91 issues = response[
'issues']
93 print (
'Key'.ljust(20),
'Summary'.ljust(20))
94 print (
'---'.ljust(20),
'-------'.ljust(20))
96 print (issue[
'key'].ljust(20), issue[
'fields'][
'summary'].ljust(20))