util/abuild: Set exit status on failure

Currently, the what-jenkins-does target doesn't stop if abuild fails.
This change gives a command line parameter to abuild with tells it to
exit with a non-zero exit status if any of the builds failed.

This will be particularly useful for concourse which doesn't parse the
junit.xml files, and only knows whether a build passed or failed by the
exit status.

Change-Id: Ic2be5deaedacd3f55db8e0b14a2b7b39cc44664e
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/20656
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Chris Ching <chingcodes@google.com>
This commit is contained in:
Martin Roth 2017-07-19 14:13:07 -06:00
parent 6c1c9d5d5f
commit ba973bd2de
1 changed files with 10 additions and 2 deletions

View File

@ -50,6 +50,9 @@ configureonly=0
# Did any board fail to build? # Did any board fail to build?
failed=0 failed=0
# Exit with a non-zero errorlevel on failure
exitcode=0
# default: don't save checksums # default: don't save checksums
checksum_file="" checksum_file=""
@ -529,6 +532,7 @@ Options:\n"
[-c|--cpus <numcpus>] Build on <numcpus> at the same time [-c|--cpus <numcpus>] Build on <numcpus> at the same time
[-C|--config] Configure-only mode [-C|--config] Configure-only mode
[-d|--dir <dir>] Directory containing config files [-d|--dir <dir>] Directory containing config files
[-e|--exitcode] Exit with a non-zero errorlevel on failure
[-J|--junit] Write JUnit formatted xml log file [-J|--junit] Write JUnit formatted xml log file
[-K|--kconfig <name>] Prepend file to generated Kconfig [-K|--kconfig <name>] Prepend file to generated Kconfig
[-l|--loglevel <num>] Set loglevel [-l|--loglevel <num>] Set loglevel
@ -599,12 +603,12 @@ getoptbrand="$(getopt -V)"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if [ "${getoptbrand:0:6}" == "getopt" ]; then if [ "${getoptbrand:0:6}" == "getopt" ]; then
# Detected GNU getopt that supports long options. # Detected GNU getopt that supports long options.
args=$(getopt -l version,verbose,quiet,help,all,target:,payloads:,cpus:,silent,junit,config,loglevel:,remove,prefix:,update,scan-build,ccache,blobs,clang,clean,outdir:,chromeos,xmlfile:,kconfig:,dir:,root:,recursive,checksum:,timeless -o Vvqhat:p:c:sJCl:rP:uyBLzo:xX:K:d:R:I -- "$@") || exit 1 args=$(getopt -l version,verbose,quiet,help,all,target:,payloads:,cpus:,silent,junit,config,loglevel:,remove,prefix:,update,scan-build,ccache,blobs,clang,clean,outdir:,chromeos,xmlfile:,kconfig:,dir:,root:,recursive,checksum:,timeless,exitcode -o Vvqhat:p:c:sJCl:rP:uyBLzo:xX:K:d:R:Ie -- "$@") || exit 1
eval set -- $args eval set -- $args
retval=$? retval=$?
else else
# Detected non-GNU getopt # Detected non-GNU getopt
args=$(getopt Vvqhat:p:c:sJCl:rP:uyBLzo:xX:K:d:R:I "$@") args=$(getopt Vvqhat:p:c:sJCl:rP:uyBLzo:xX:K:d:R:Ie "$@")
set -- $args set -- $args
retval=$? retval=$?
fi fi
@ -627,6 +631,7 @@ while true ; do
-t|--target) shift; target="$1"; shift;; -t|--target) shift; target="$1"; shift;;
-a|--all) shift; buildall=true;; -a|--all) shift; buildall=true;;
-d|--dir) shift; configdir="$1"; shift;; -d|--dir) shift; configdir="$1"; shift;;
-e|--exitcode) shift; exitcode=1;;
-r|--remove) shift; remove=true;; -r|--remove) shift; remove=true;;
-v|--verbose) shift; verbose=true; verboseopt='V=1';; -v|--verbose) shift; verbose=true; verboseopt='V=1';;
-q|--quiet) shift; quiet=true;; -q|--quiet) shift; quiet=true;;
@ -848,6 +853,9 @@ if [ "$recursive" = "false" ]; then
printf "%s configuration(s) failed:\n" "$( wc -l < "$FAILED_BOARDS" )" printf "%s configuration(s) failed:\n" "$( wc -l < "$FAILED_BOARDS" )"
cat "$FAILED_BOARDS" cat "$FAILED_BOARDS"
echo echo
if [ "$exitcode" != "0" ]; then
failed=1
fi
else else
printf "All %s tested configurations passed.\n" "$( wc -l < "$PASSED_BOARDS" )" printf "All %s tested configurations passed.\n" "$( wc -l < "$PASSED_BOARDS" )"
fi fi