summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-08-05 12:11:39 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-08-06 16:50:09 +0100
commita7ef7e54fa927bab5b649a8aac6111f02d6ba34f (patch)
treed8809d89e298d5bad96cf00c9be8a0163e36c05b
parentb46c79278b0715dc34257fdee056f5d50e87dd88 (diff)
ci: Report failures via email
When an error is detected send a mail report out. This is currently a hardcoded destination which can be factored out later. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rwxr-xr-xcommon.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/common.sh b/common.sh
index 7e21eb1..bc7988f 100755
--- a/common.sh
+++ b/common.sh
@@ -56,12 +56,33 @@ check_version() {
fi
}
+failure_report() {
+ echo "Subject: $0: $1 has failed"
+ echo ""
+ echo "$1 has failed"
+ echo " --- 8< --- "
+ cat $2
+ echo " --- >8 --- "
+}
+
+SENDMAIL=$(which sendmail)
+notify_failures() {
+ if [ x"$SENDMAIL" == x"" ];
+ then
+ echo "No mail client to notify failures..."
+ return
+ fi
+
+ failure_report "$1" "$2" | sendmail kieran.bingham@ideasonboard.com
+}
+
pass_fail() {
if [ "$1" -ne 0 ]; then
echo " $2: *** Failed ***"
if [ -e $logfile ]; then
cat $logfile;
fi
+ notify_failures "$2" "$logfile"
exit "$1"
else
echo " $2: Passed"