import sys
import base64
import xml.etree.cElementTree as ElementTree
-
+
+from common.buildservice import BuildService
from common.buildtrigger import trigger_info
from common.send_mail import prepare_mail
-def send_mail_buildstatus(info):
+def send_mail_buildstatus(info, test_status=None):
""" send mail about buildstatus """
- EMAIL_TITLE = "SR[%s] %s %s"
- EMAIL_BODY = "The status of SR has been updated.\n" \
+ EMAIL_TITLE = "SR[%s] %s %s %s"
+ EMAIL_BODY = "The status of the SR has been updated.\n" \
"Please check the following details.\n\n" \
"SR tag: %s\n" \
"Packages : %s\n\n" \
"Result\n" \
"Build : %s\n" \
"Image : %s\n" \
+ "Test : %s\n\n" \
"For more details, please refer to %s"
EMAIL_FOOTER = '\n\n--------------------------------------------------------\n'\
imgstatus=None
dashboard_url = os.path.join(os.getenv('DASHBOARD_URL'), "index.code?sr=" + info.get('git_tag'))
+ if test_status:
+ if test_status == 'S':
+ title_test = 'Test(Succeeded)'
+ teststatus = 'success'
+ else:
+ title_test = 'Test(Failed)'
+ teststatus = 'failed'
+ else:
+ title_test =""
+ teststatus =""
#make a message
- title = EMAIL_TITLE % (info.get('git_tag'), title_build, title_image)
- email_body = EMAIL_BODY % ( info.get('git_tag'), info.get('packages'), buildstatus, imgstatus, dashboard_url)
+ title = EMAIL_TITLE % (info.get('git_tag'), title_build, title_image, title_test)
+ email_body = EMAIL_BODY % ( info.get('git_tag'), info.get('packages'), buildstatus, imgstatus, teststatus, dashboard_url)
msg = 'Hello \n\n' + email_body + EMAIL_FOOTER
print submitters
print title
def main():
"""The main body"""
- saved_info = trigger_info(os.getenv('TRIGGER_INFO'))
+ obs_api = os.getenv("OBS_API_URL")
+ obs_user = os.getenv("OBS_API_USERNAME")
+ obs_passwd = os.getenv("OBS_API_PASSWD")
+
+ content = trigger_info(os.getenv('TRIGGER_INFO'))
+
+ build = BuildService(obs_api, obs_user, obs_passwd)
+ if content.get('project'):
+ project = content.get('project')
+ test_status = content.get('status')
+ else:
+ project = content.get('obs_url').split('project=')[-1]
+ test_status = None
- project = saved_info.get('obs_url').split('project=')[-1]
if project is None:
raise LocalError('Please check the project (%s)' \
% (project))
- send_mail_buildstatus(saved_info)
+ saved_info = build.get_info(project)
+ send_mail_buildstatus(saved_info, test_status)
if __name__ == '__main__':
sys.exit(main())
import re
import datetime
from codebase import *
+from common.buildtrigger import trigger_info, trigger_next
+
+def notify_test_result(MYSQL, build_project_id, status):
+ """
+ Notify the test results to submitters
+ """
+ sql_data = (build_project_id,)
+ sql = "SELECT ip.project_name FROM info_project ip, build_project bp WHERE ip.id = bp.info_project_id AND bp.id = %s"
+ MYSQL['cursor'].execute(sql, sql_data)
+ row = MYSQL['cursor'].fetchall()
+ if len(row) > 0:
+ project_name = row[0]['project_name']
+ print project_name
+ data = {"project" : project_name,
+ "status" : status
+ }
+ trigger_next("NOTIFY-BUILDSTATUS", data)
def is_test_succeeded(data, is_ref_exist, is_perf_exist):
MYSQL['cursor'].execute(sql, sql_data)
MYSQL['connection'].commit()
+ # Add notify status
+ notify_test_result(MYSQL, build_project_id, status)
if __name__ == "__main__":