yocto-autobuilder-helper/scripts/send-qa-email
Richard Purdie b7cf6d8209 utils: Allow customisation using ABHELPER_JSON from the environment
Usage is documented in README and an example, local-example.json is
included.

Also clean up the parameter to loadconfig() as its actually not needed.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-06-20 23:16:10 +01:00

2.3 KiB
Executable File

#!/usr/bin/env python3

Iterate over a set of configurations from json.conf, calling setup-config for each one, then running the build.

Called with $1 - The json file containing the repositories to use

$2 - Where the artefacts were published

$3 - The build/release 'name' for release purposes

$4 - The shared repos directory (to resolve the repo revision hashes)

import json import os import sys import subprocess import errno

import utils

if len(sys.argv) != 6: print("Incorrect number of parameters, please call as %s " % sys.argv[0]) sys.exit(1)

send = sys.argv[1] repojson = sys.argv[2] publish = sys.argv[3] rel_name = sys.argv[4] repodir = sys.argv[5]

if send != "True" or publish == "None" or rel_name == "None": utils.printheader("Not sending QA email") sys.exit(0)

scriptsdir = os.path.dirname(os.path.realpath(file)) ourconfig = utils.loadconfig()

with open(repojson) as f: repos = json.load(f)

buildhashes = "" for repo in sorted(repos.keys()): # Need the finalised revisions (not 'HEAD') targetrepodir = "%s/%s" % (repodir, repo) revision = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=targetrepodir).decode('utf-8').strip() buildhashes += "%s: %s\n" % (repo, revision)

web_root = utils.getconfig('WEBPUBLISH_DIR', ourconfig) web_url = utils.getconfig('WEBPUBLISH_URL', ourconfig)

email = "" mailto = utils.getconfig("QAMAIL_TO", ourconfig) if mailto: email += "To: " + mailto + "\n" mailcc = utils.getconfig("QAMAIL_CC", ourconfig) if mailcc: email += "Cc: " + mailcc + "\n" mailbcc = utils.getconfig("QAMAIL_BCC", ourconfig) if mailbcc: email += "Bcc: " + mailbcc + "\n"

email += "Subject: " + "QA notification for completed autobuilder build (%s)\n" % rel_name email += '''\n A build flagged for QA (%s) was completed on the autobuilder and is available at:\n\n %s\n\n Build hash information: \n %s

\nThis is an automated message from the Yocto Project Autobuilder\nGit: git://git.yoctoproject.org/yocto-autobuilder2\nEmail: richard.purdie@linuxfoundation.org\n

''' % (rel_name, publish.replace(web_root, web_url), buildhashes)

utils.printheader("Sending QA email") subprocess.check_call('echo "' + email +' " | sendmail -t', shell=True)