mirror of https://github.com/apache/kafka.git
KAFKA-1854 Allow JIRA username and password to be prompted in the absence of a jira.ini file, during patch submission; reviewed by Neha Narkhede
This commit is contained in:
parent
688e38ce45
commit
e79ebdfe22
|
@ -7,22 +7,31 @@ import time
|
||||||
import datetime
|
import datetime
|
||||||
import tempfile
|
import tempfile
|
||||||
import commands
|
import commands
|
||||||
|
import getpass
|
||||||
from jira.client import JIRA
|
from jira.client import JIRA
|
||||||
|
|
||||||
def get_jira_config():
|
def get_jira_config():
|
||||||
# read the config file
|
# read the config file
|
||||||
home=jira_home=os.getenv('HOME')
|
home=jira_home=os.getenv('HOME')
|
||||||
home=home.rstrip('/')
|
home=home.rstrip('/')
|
||||||
jira_config = dict(line.strip().split('=') for line in open(home + '/jira.ini'))
|
if not (os.path.isfile(home + '/jira.ini')):
|
||||||
return jira_config
|
jira_user=raw_input('JIRA user :')
|
||||||
|
jira_pass=getpass.getpass('JIRA password :')
|
||||||
|
jira_config = {'user':jira_user, 'password':jira_pass}
|
||||||
|
return jira_config
|
||||||
|
else:
|
||||||
|
jira_config = dict(line.strip().split('=') for line in open(home + '/jira.ini'))
|
||||||
|
return jira_config
|
||||||
|
|
||||||
def get_jira():
|
def get_jira(jira_config):
|
||||||
options = {
|
options = {
|
||||||
'server': 'https://issues.apache.org/jira'
|
'server': 'https://issues.apache.org/jira'
|
||||||
}
|
}
|
||||||
|
|
||||||
jira_config = get_jira_config()
|
|
||||||
jira = JIRA(options=options,basic_auth=(jira_config['user'], jira_config['password']))
|
jira = JIRA(options=options,basic_auth=(jira_config['user'], jira_config['password']))
|
||||||
|
# (Force) verify the auth was really done
|
||||||
|
jira_session=jira.session()
|
||||||
|
if (jira_session is None):
|
||||||
|
raise Exception("Failed to login to the JIRA instance")
|
||||||
return jira
|
return jira
|
||||||
|
|
||||||
def cmd_exists(cmd):
|
def cmd_exists(cmd):
|
||||||
|
@ -81,6 +90,15 @@ def main():
|
||||||
p=os.popen(git_remote_update)
|
p=os.popen(git_remote_update)
|
||||||
p.close()
|
p.close()
|
||||||
|
|
||||||
|
# Get JIRA configuration and login to JIRA to ensure the credentials work, before publishing the patch to the review board
|
||||||
|
print "Verifying JIRA connection configurations"
|
||||||
|
try:
|
||||||
|
jira_config=get_jira_config()
|
||||||
|
jira=get_jira(jira_config)
|
||||||
|
except:
|
||||||
|
print "Failed to login to the JIRA instance", sys.exc_info()[0], sys.exc_info()[1]
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
rb_command= post_review_tool + " --publish --tracking-branch " + opt.branch + " --target-groups=kafka --bugs-closed=" + opt.jira
|
rb_command= post_review_tool + " --publish --tracking-branch " + opt.branch + " --target-groups=kafka --bugs-closed=" + opt.jira
|
||||||
if opt.debug:
|
if opt.debug:
|
||||||
rb_command=rb_command + " --debug"
|
rb_command=rb_command + " --debug"
|
||||||
|
@ -123,7 +141,6 @@ def main():
|
||||||
p.close()
|
p.close()
|
||||||
|
|
||||||
print 'Creating diff against', opt.branch, 'and uploading patch to JIRA',opt.jira
|
print 'Creating diff against', opt.branch, 'and uploading patch to JIRA',opt.jira
|
||||||
jira=get_jira()
|
|
||||||
issue = jira.issue(opt.jira)
|
issue = jira.issue(opt.jira)
|
||||||
attachment=open(patch_file)
|
attachment=open(patch_file)
|
||||||
jira.add_attachment(issue,attachment)
|
jira.add_attachment(issue,attachment)
|
||||||
|
@ -146,8 +163,6 @@ def main():
|
||||||
for t in transitions:
|
for t in transitions:
|
||||||
transitionsMap[t['name']] = t['id']
|
transitionsMap[t['name']] = t['id']
|
||||||
|
|
||||||
jira_config = get_jira_config()
|
|
||||||
|
|
||||||
if('Submit Patch' in transitionsMap):
|
if('Submit Patch' in transitionsMap):
|
||||||
jira.transition_issue(issue, transitionsMap['Submit Patch'] , assignee={'name': jira_config['user']} )
|
jira.transition_issue(issue, transitionsMap['Submit Patch'] , assignee={'name': jira_config['user']} )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue