mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7690 from heliclei/jenkins-job-trigger
use github access token to retrive commits
This commit is contained in:
commit
9eff58b0a5
|
@ -8,6 +8,9 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
from jenkinsapi.jenkins import Jenkins
|
from jenkinsapi.jenkins import Jenkins
|
||||||
|
|
||||||
|
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||||
|
Headers = {"Authorization":"token " + access_token}
|
||||||
|
|
||||||
http_proxy = ''
|
http_proxy = ''
|
||||||
if(os.environ.has_key('HTTP_PROXY')):
|
if(os.environ.has_key('HTTP_PROXY')):
|
||||||
http_proxy = os.environ['HTTP_PROXY']
|
http_proxy = os.environ['HTTP_PROXY']
|
||||||
|
@ -28,8 +31,6 @@ def check_queue_build(action, pr_num, statuses_url):
|
||||||
queues.delete_item(queue)
|
queues.delete_item(queue)
|
||||||
target_url = os.environ['JOB_PULL_REQUEST_BUILD_URL']
|
target_url = os.environ['JOB_PULL_REQUEST_BUILD_URL']
|
||||||
data = {"state":"error", "target_url":target_url}
|
data = {"state":"error", "target_url":target_url}
|
||||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
|
||||||
Headers = {"Authorization":"token " + access_token}
|
|
||||||
try:
|
try:
|
||||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict)
|
requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict)
|
||||||
except:
|
except:
|
||||||
|
@ -76,7 +77,7 @@ def main():
|
||||||
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
|
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
r = requests.get(pr['url']+"/commits", proxies = proxyDict)
|
r = requests.get(pr['url']+"/commits", headers=Headers, proxies = proxyDict)
|
||||||
commits = r.json()
|
commits = r.json()
|
||||||
last_commit = commits[len(commits)-1]
|
last_commit = commits[len(commits)-1]
|
||||||
message = last_commit['commit']['message']
|
message = last_commit['commit']['message']
|
||||||
|
@ -91,8 +92,7 @@ def main():
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Waiting available build machine..."}
|
data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Waiting available build machine..."}
|
||||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
|
||||||
Headers = {"Authorization":"token " + access_token}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict)
|
requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict)
|
||||||
|
|
Loading…
Reference in New Issue