8 from __future__
import print_function
10 __doc__ =
"Interface with CERN JIRA instance."
11 __author__ =
"Edward Moyse"
17 import PyUtils.acmdlib
as acmdlib
23 base_url =
"https://its.cern.ch/jira/rest/api/2/"
24 url = base_url+querystring
26 r = requests.get(url, cookies=cookies)
27 if r.status_code != 200:
28 if r.status_code == 401:
29 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" ')
31 print (
"Something has gone wrong! The response is: ", r.text)
35 response = json.loads(r.text)
38 @acmdlib.command(name=
'jira.issues')
39 @acmdlib.argument(
'-c',
'--cookies',
42 help=
'the CERN SSO cookies file')
43 @acmdlib.argument(
'-r',
'--release',
45 help=
'Limit the response to the specified release')
46 @acmdlib.argument(
'-m',
'--myissues',
50 help=
'Limit the response your own issues')
51 @acmdlib.argument(
'-q',
'--query',
53 help=
'Use the specified query string i.e. "search?jql=assignee=currentUser()+and+resolution=Unresolved"')
54 @acmdlib.argument(
'-s',
'--status',
56 help=
'Limit the search to issues with this status, e.g. "Open"')
59 """Interface to the CERN JIRA instance"""
63 cookiesFile =
open(args.cookies,
'r')
65 for line
in cookiesFile:
67 if 'JSESSIONID' in line:
68 cookies[
'JSESSIONID'] = text[-1]
69 if 'atlassian.xsrf.token' in line:
70 cookies[
'atlassian.xsrf.token'] = text[-1]
72 print (
"Problems opening cookie file at ", args.cookies)
77 print (
"Will use the following search string: ",args.query)
78 querystring = args.query
80 querystring =
"search?jql=resolution=Unresolved"
82 querystring +=
"+AND+assignee=currentUser()"
84 querystring +=
"+AND+affectedVersion="+args.release
86 querystring +=
"+AND+status="+args.status
88 response =
queryJira(querystring, cookies)
93 issues = response[
'issues']
95 print (
'Key'.ljust(20),
'Summary'.ljust(20))
96 print (
'---'.ljust(20),
'-------'.ljust(20))
98 print (issue[
'key'].ljust(20), issue[
'fields'][
'summary'].ljust(20))