mirror of https://github.com/axmolengine/axmol.git
[Jenkins][ci skip]: Monitor jenkins queue build
This commit is contained in:
parent
f998ea058a
commit
7f1d694f03
|
@ -6,6 +6,21 @@ import os
|
|||
import requests
|
||||
import sys
|
||||
import traceback
|
||||
from jenkinsapi.jenkins import Jenkins
|
||||
|
||||
def check_queue_build(action, pr_num, statuses_url):
|
||||
username = os.environ['JENKINS_ADMIN']
|
||||
password = os.environ['JENKINS_ADMIN_PW']
|
||||
J = Jenkins('http://115.28.134.83:8000',username,password)
|
||||
queues = J.get_queue()
|
||||
for key,queue in queues.iteritems():
|
||||
q_payload_str = queue.get_parameters()['payload'].decode('utf-8','ignore')
|
||||
q_payload = json.loads(q_payload_str)
|
||||
q_pr_num = q_payload['number']
|
||||
q_statuses_url = q_payload['statuses_url']
|
||||
if(q_pr_num == pr_num):
|
||||
if(action == 'closed') or (q_statuses_url != statuses_url):
|
||||
queues.delete_item(queue)
|
||||
|
||||
def main():
|
||||
#get payload from os env
|
||||
|
@ -40,6 +55,7 @@ def main():
|
|||
target_url = os.environ['JOB_PULL_REQUEST_BUILD_URL']
|
||||
|
||||
if(action == 'closed'):
|
||||
check_queue_build(action, pr_num, statuses_url)
|
||||
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
|
||||
return(0)
|
||||
|
||||
|
@ -63,6 +79,7 @@ def main():
|
|||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
check_queue_build(action, pr_num, statuses_url)
|
||||
job_trigger_url = os.environ['JOB_TRIGGER_URL']
|
||||
#send trigger and payload
|
||||
post_data = {'payload':""}
|
||||
|
|
Loading…
Reference in New Issue