disable comment job trigger for v2 branch

This commit is contained in:
andyque 2015-04-13 09:57:49 +08:00
parent fdb03f150d
commit 68f86adab1
1 changed files with 30 additions and 28 deletions

View File

@ -7,7 +7,7 @@ import traceback
import urllib2
http_proxy = ''
if(os.environ.has_key('HTTP_PROXY')):
if('HTTP_PROXY' in os.environ):
http_proxy = os.environ['HTTP_PROXY']
proxyDict = {'http': http_proxy, 'https': http_proxy}
@ -75,11 +75,12 @@ def main():
#set commit status to pending
target_url = os.environ['JOB_PULL_REQUEST_BUILD_URL']
if(action == 'closed' or action == 'assigned'):
if(action == 'closed' or action == 'assigned' or branch == 'v2'):
print 'pull request #' + str(pr_num) + ' is ' + action + ', no build triggered'
return(0)
data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Wait available build machine..."}
data = {"state": "pending", "target_url": target_url, "context": "Jenkins CI",
"description": "Wait available build machine..."}
access_token = os.environ['GITHUB_ACCESS_TOKEN']
Headers = {"Authorization": "token " + access_token}
@ -87,7 +88,8 @@ def main():
if searchCI:
ciOper = searchCI.group()
if('rebuild' in ciOper):
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:
traceback.print_exc()