Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_bug_fix

This commit is contained in:
samuele3hu 2014-06-23 17:43:07 +08:00
commit a73e7c643b
1 changed files with 35 additions and 0 deletions

View File

@ -4,6 +4,39 @@ import requests
import jenkinsapi import jenkinsapi
from jenkinsapi.jenkins import Jenkins from jenkinsapi.jenkins import Jenkins
from jenkinsapi.constants import STATUS_SUCCESS from jenkinsapi.constants import STATUS_SUCCESS
from email.mime.text import MIMEText
import smtplib
def send_mail(sub,title,content):
#to_list = os.environ['EMAIL_LIST'].split(' ')
mail_user = os.environ['EMAIL_USER']
mail_pass = os.environ['EMAIL_PWD']
to_list = os.environ['EMAIL_LIST'].split(' ')
mail_postfix = 'gmail.com'
me = mail_user + "<" + mail_user + "@" + mail_postfix + ">"
msg = MIMEText(content, _subtype='plain', _charset='gb2312')
msg['Subject'] = sub
msg['From'] = me
msg['To'] = " ".join(to_list)
print 'to users:', msg['To']
msg['Content'] = 'test'
try:
s = smtplib.SMTP('smtp.gmail.com', 587)
s.ehlo()
s.starttls()
s.login(mail_user,mail_pass)
s.sendmail(me, to_list, str(msg))
print 'info:', me, to_list, str(msg)
s.close()
return True
except Exception, e:
print str(e)
return False
def sendEmail(pr, html_url, target_url):
sub = "Pull request #" + str(pr) + " build is failed!"
title = "build failed!"
content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url
send_mail(sub, title, content)
payload_str = os.environ['payload'] payload_str = os.environ['payload']
payload_str = payload_str.decode('utf-8','ignore') payload_str = payload_str.decode('utf-8','ignore')
@ -12,6 +45,7 @@ payload = json.loads(payload_str)
#pr = payload['pull_request'] #pr = payload['pull_request']
url = payload['html_url'] url = payload['html_url']
print "build pr:" + url print "build pr:" + url
pr_num = payload['number']
#get statuses url #get statuses url
statuses_url = payload['statuses_url'] statuses_url = payload['statuses_url']
@ -30,6 +64,7 @@ if(result == STATUS_SUCCESS):
else: else:
data['state'] = "failure" data['state'] = "failure"
data['description'] = "Build failed!" data['description'] = "Build failed!"
sendEmail(pr_num, url, target_url)
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']