mirror of https://github.com/axmolengine/axmol.git
fix jenkins sql table name
This commit is contained in:
parent
f11c287ab6
commit
9e538fce48
|
@ -1,4 +1,4 @@
|
||||||
#Github pull reqest builder for Jenkins
|
#Github pull reqest builder for Jenkins
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -22,7 +22,7 @@ def set_description(desc, url):
|
||||||
req_data = urllib.urlencode({'description': desc})
|
req_data = urllib.urlencode({'description': desc})
|
||||||
req = urllib2.Request(url + 'submitDescription', req_data)
|
req = urllib2.Request(url + 'submitDescription', req_data)
|
||||||
#print(os.environ['BUILD_URL'])
|
#print(os.environ['BUILD_URL'])
|
||||||
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '')
|
base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '')
|
||||||
req.add_header("Authorization", "Basic " + base64string)
|
req.add_header("Authorization", "Basic " + base64string)
|
||||||
try:
|
try:
|
||||||
|
@ -77,7 +77,7 @@ def close_db(db):
|
||||||
|
|
||||||
def save_build_stats(db, pr, filename, size):
|
def save_build_stats(db, pr, filename, size):
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
sql = "INSERT INTO %s (number, size, createdTime) VALUES(%d, %d, now())" % (filename, pr, size)
|
sql = "INSERT INTO \"%s\" (number, size, createdTime) VALUES(%d, %d, now())" % (filename, pr, size)
|
||||||
print sql
|
print sql
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
@ -118,11 +118,11 @@ def main():
|
||||||
print 'action: ' + action
|
print 'action: ' + action
|
||||||
|
|
||||||
#pr = payload['pull_request']
|
#pr = payload['pull_request']
|
||||||
|
|
||||||
url = payload['html_url']
|
url = payload['html_url']
|
||||||
print "url:" + url
|
print "url:" + url
|
||||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + ' is '+ action +'</a></h3>'
|
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + ' is '+ action +'</a></h3>'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#get statuses url
|
#get statuses url
|
||||||
|
@ -139,11 +139,11 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Build started..."}
|
data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Build started..."}
|
||||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||||
Headers = {"Authorization":"token " + 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)
|
||||||
|
@ -157,14 +157,14 @@ def main():
|
||||||
os.system("git checkout v3")
|
os.system("git checkout v3")
|
||||||
os.system("git branch -D pull" + str(pr_num))
|
os.system("git branch -D pull" + str(pr_num))
|
||||||
#clean workspace
|
#clean workspace
|
||||||
print "Before checkout: git clean -xdf -f"
|
print "Before checkout: git clean -xdf -f"
|
||||||
os.system("git clean -xdf -f")
|
os.system("git clean -xdf -f")
|
||||||
#fetch pull request to local repo
|
#fetch pull request to local repo
|
||||||
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head"
|
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head"
|
||||||
ret = os.system(git_fetch_pr)
|
ret = os.system(git_fetch_pr)
|
||||||
if(ret != 0):
|
if(ret != 0):
|
||||||
return(2)
|
return(2)
|
||||||
|
|
||||||
#checkout a new branch from v3
|
#checkout a new branch from v3
|
||||||
git_checkout = "git checkout -b " + "pull" + str(pr_num)
|
git_checkout = "git checkout -b " + "pull" + str(pr_num)
|
||||||
os.system(git_checkout)
|
os.system(git_checkout)
|
||||||
|
@ -175,9 +175,9 @@ def main():
|
||||||
if r.find('CONFLICT') > 0:
|
if r.find('CONFLICT') > 0:
|
||||||
print r
|
print r
|
||||||
return(3)
|
return(3)
|
||||||
|
|
||||||
# After checkout a new branch, clean workspace again
|
# After checkout a new branch, clean workspace again
|
||||||
print "After checkout: git clean -xdf -f"
|
print "After checkout: git clean -xdf -f"
|
||||||
os.system("git clean -xdf -f")
|
os.system("git clean -xdf -f")
|
||||||
|
|
||||||
#update submodule
|
#update submodule
|
||||||
|
@ -214,7 +214,7 @@ def main():
|
||||||
print platform.system()
|
print platform.system()
|
||||||
if(platform.system() == 'Darwin'):
|
if(platform.system() == 'Darwin'):
|
||||||
for item in PROJECTS:
|
for item in PROJECTS:
|
||||||
cmd = "ln -s " + os.environ['WORKSPACE']+"/android_build_objs/ " + os.environ['WORKSPACE']+"/tests/"+item+"/proj.android/obj"
|
cmd = "ln -s " + os.environ['WORKSPACE']+"/android_build_objs/ " + os.environ['WORKSPACE']+"/tests/"+item+"/proj.android/obj"
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
elif(platform.system() == 'Windows'):
|
elif(platform.system() == 'Windows'):
|
||||||
for item in PROJECTS:
|
for item in PROJECTS:
|
||||||
|
@ -222,7 +222,7 @@ def main():
|
||||||
cmd = "mklink /J "+os.environ['WORKSPACE']+os.sep+"tests"+os.sep +p+os.sep+"proj.android"+os.sep+"obj " + os.environ['WORKSPACE']+os.sep+"android_build_objs"
|
cmd = "mklink /J "+os.environ['WORKSPACE']+os.sep+"tests"+os.sep +p+os.sep+"proj.android"+os.sep+"obj " + os.environ['WORKSPACE']+os.sep+"android_build_objs"
|
||||||
print cmd
|
print cmd
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
|
|
||||||
#build
|
#build
|
||||||
#TODO: add android-linux build
|
#TODO: add android-linux build
|
||||||
#TODO: add mac build
|
#TODO: add mac build
|
||||||
|
@ -306,13 +306,13 @@ def main():
|
||||||
|
|
||||||
#get build result
|
#get build result
|
||||||
print "build finished and return " + str(ret)
|
print "build finished and return " + str(ret)
|
||||||
|
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
exit_code = 0
|
exit_code = 0
|
||||||
else:
|
else:
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
|
|
||||||
#clean workspace
|
#clean workspace
|
||||||
os.system("cd " + os.environ['WORKSPACE'])
|
os.system("cd " + os.environ['WORKSPACE'])
|
||||||
os.system("git reset --hard")
|
os.system("git reset --hard")
|
||||||
|
@ -325,7 +325,7 @@ def main():
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys_ret = 0
|
sys_ret = 0
|
||||||
try:
|
try:
|
||||||
sys_ret = main()
|
sys_ret = main()
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
Loading…
Reference in New Issue