axmol/tools/jenkins-scripts/utils/create-job.py

33 lines
725 B
Python
Raw Normal View History

2014-01-06 20:58:00 +08:00
#create ghprb job by pr number
import sys
import json
import requests
#get pr number from cmd
pr_num = sys.argv[1]
#get github access token
2014-01-06 20:58:00 +08:00
#get pr data via github api
2015-03-10 14:08:03 +08:00
api_get_pr = "https://api.github.com/repos/cocos2d/cocos2d-x/pulls/" + str(pr_num)
2014-01-06 20:58:00 +08:00
r = requests.get(api_get_pr)
pr = r.json()
#forge a payload
2015-03-10 14:08:03 +08:00
payload = {"action": "opened", "number": "", "pull_request": ""}
payload['number'] = pr_num
payload['pull_request'] = pr
2014-01-06 20:58:00 +08:00
2015-03-10 14:08:03 +08:00
jenkins_job_url = "http://115.28.134.83:8000/job/ccs-pr"
jenkins_trigger_url = jenkins_job_url + "/buildWithParameters?token=ced2014"
2014-01-06 20:58:00 +08:00
#send trigger and payload
2015-03-10 14:08:03 +08:00
post_data = {'payload': ""}
post_data['payload'] = json.dumps(payload)
2014-01-06 20:58:00 +08:00
requests.post(jenkins_trigger_url, data=post_data)