Merge pull request #7485 from heliclei/save-build-result

[ci skip][jenkins]record size of libcpp_empty_test.so to database
This commit is contained in:
minggo 2014-07-17 15:12:30 +08:00
commit 9329c77f2a
1 changed files with 18 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import platform
import subprocess import subprocess
import codecs import codecs
from shutil import copy from shutil import copy
import MySQLdb
#set Jenkins build description using submitDescription to mock browser behavior #set Jenkins build description using submitDescription to mock browser behavior
#TODO: need to set parent build description #TODO: need to set parent build description
@ -61,10 +62,25 @@ def check_current_3rd_libs(branch):
current_file = current_files[i] current_file = current_files[i]
copy(current_file, backup_file) copy(current_file, backup_file)
def save_build_stats(pr_num, key, value):
db_host = os.environ['db_host']
db_user = os.environ['db_user']
db_pw = os.environ['db_pw']
db = MySQLdb.connect(db_host, db_user, db_pw, "jenkins" )
cursor = db.cursor()
sql = '''INSERT INTO PullRequestBuild (pr_number, %s)
VALUES(%d, %d) ON DUPLICATE KEY UPDATE pr_number=VALUES(pr_number),
%s=VALUES(%s)''' % (key, pr_num, value, key, key)
print sql
cursor.execute(sql)
db.commit()
db.close()
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']
proxyDict = {'http':http_proxy,'https':http_proxy} proxyDict = {'http':http_proxy,'https':http_proxy}
def main(): def main():
#get payload from os env #get payload from os env
payload_str = os.environ['payload'] payload_str = os.environ['payload']
@ -205,8 +221,9 @@ def main():
if(ret == 0): if(ret == 0):
_path = 'tests/cpp-empty-test/proj.android/libs/armeabi/libcpp_empty_test.so' _path = 'tests/cpp-empty-test/proj.android/libs/armeabi/libcpp_empty_test.so'
filesize = os.path.getsize(_path) filesize = os.path.getsize(_path)
pr_desc = pr_desc + '<br /><h3>size of libcpp_empty_test.so is:' + str(filesize/1024) + 'kb</h3>' pr_desc = pr_desc + '<h3>size of libcpp_empty_test.so is:' + str(filesize/1024) + 'kb</h3>'
set_description(pr_desc, target_url) set_description(pr_desc, target_url)
save_build_stats(pr_num, 'cpp_empty_test_so', filesize/1024)
elif(node_name == 'win32_win7'): elif(node_name == 'win32_win7'):
ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True) ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True)
elif(node_name == 'ios_mac'): elif(node_name == 'ios_mac'):