[Jenkins][ci skip] Change 'payload' to 'tag'

This commit is contained in:
lm 2014-04-23 18:10:39 +08:00
parent 55911e1e78
commit 41615fe56a
2 changed files with 10 additions and 27 deletions

View File

@ -48,25 +48,14 @@ def make_temp_dir():
os.system(cmd) os.system(cmd)
def main(): def main():
#get payload from os env #get tag
payload_str = os.environ['payload'] tag = os.environ['tag']
payload_str = payload_str.decode('utf-8','ignore')
#parse to json obj
payload = json.loads(payload_str)
#get pull number
tag = payload['tag']
print 'tag:' + tag print 'tag:' + tag
url = payload['html_url'] pr_desc = '<h3>' + tag + ' is release' + '</h3>'
print "url:" + url
pr_desc = '<h3><a href=' + url + '>' + tag + ' is release' + '</a></h3>'
#get statuses url
statuses_url = payload['statuses_url']
#get pr target branch #get pr target branch
branch = payload['branch'] branch = 'develop'
#set parent build description #set parent build description
jenkins_url = os.environ['JENKINS_URL'] jenkins_url = os.environ['JENKINS_URL']
@ -75,16 +64,6 @@ def main():
target_url = jenkins_url + 'job/' + job_name + '/' + build_number + '/' target_url = jenkins_url + 'job/' + job_name + '/' + build_number + '/'
set_description(pr_desc, target_url) set_description(pr_desc, target_url)
#set commit status to pending
data = {"state":"pending", "target_url":target_url}
access_token = os.environ['GITHUB_ACCESS_TOKEN']
Headers = {"Authorization":"token " + access_token}
try:
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
except:
traceback.print_exc()
#pull origin develop #pull origin develop
os.system('git reset --hard') os.system('git reset --hard')

View File

@ -106,8 +106,12 @@ def main():
print 'job_trigger_url is: ', job_trigger_url print 'job_trigger_url is: ', job_trigger_url
#send trigger and payload #send trigger and payload
post_data = {'payload':""} if('tag' in payload_forword):
post_data['payload']= json.dumps(payload_forword) post_data = {'tag':""}
post_data['tag'] = payload_forword['tag']
else:
post_data = {'payload':""}
post_data['payload']= json.dumps(payload_forword)
requests.post(job_trigger_url, data=post_data) requests.post(job_trigger_url, data=post_data)
return(0) return(0)