diff --git a/bin/bsauto b/bin/bsauto index 266a8ccb99bc6e159eaa66881d6f4740b8af35cd..5d9c8cfafedc44ec1228456028db7cbc1d8fdd68 100755 --- a/bin/bsauto +++ b/bin/bsauto @@ -44,9 +44,13 @@ function do_execute { eval $1 if [ $? -ne 0 ]; then touch "$BIN/.freeze" - echo "Encountered error running $1" - echo "A $BIN/.freeze file has been created" - echo "Manual intervention is now required to continue the release process" + FREEZE_MESSAGE="An error was encountered whilst running:\n\n'$1'\n\nA $BIN/.freeze file has been created.\nManual intervention is required to continue." + if [ ! -z $NOMAD_ALLOC_ID ]; then + WARNING="******************************\n*** Manual action required ***\n******************************\n\n" + do_admin_email "C7X: Release error: automation stopped" "$WARNING$FREEZE_MESSAGE" + else + echo -e $FREEZE_MESSAGE + fi exit fi fi @@ -54,6 +58,29 @@ function do_execute { echo -e $NORMAL "Completed" } +function do_admin_email { + SUBJECT=$1 + BODY=$2 + + MAILTMP=`/bin/mktemp /tmp/$DIST$$.XXXXXXXX` + echo "To: lxsoft-admins@cern.ch" >> $MAILTMP + echo "From: linux.support@cern.ch" >> $MAILTMP + echo "Reply-To: noreply.Linux.Support@cern.ch" >> $MAILTMP + echo "Return-Path: lxsoft-admins@cern.ch" >> $MAILTMP + echo "Subject: $SUBJECT" >> $MAILTMP + + echo -e "Dear admins,\n" >> $MAILTMP + # ensure shell globbing doesn't mess up our email + set -f + echo -e $BODY >> $MAILTMP + set +f + echo -e "\n---\nBest regards,\nCERN Linux Droid,\n(on behalf of the friendly humans of Linux Support" >> $MAILTMP + + /usr/sbin/sendmail -t < $MAILTMP + rm -f $MAILTMP + +} + function do_testing { INTERNAL_PACKAGES=`find /mnt/data2/home/build/packages/incoming/$DIST -type f -name *rpm` if [ "$INTERNAL_PACKAGES" != "" ]; then @@ -73,9 +100,14 @@ function do_testing { do_execute "/mnt/data2/home/build/bin/bscentos2test -d $DIST -r all" REPOLIST=`find /mnt/data2/home/build/packages/logs/build2test -size +0c -name $DIST*$DATE* | /usr/bin/cut -d. -f2` if [ "$REPOLIST" == "" ]; then - echo "No new packages today, exiting" + if [ ! -z $NOMAD_ALLOC_ID ]; then + do_admin_email "C7X: Informative: No new packages today" "Just a quick message to let you know that there were no new upstream CentOS7 packages today.\n\nHave a nice day." + else + echo "No new packages today, exiting" + fi exit fi + exit for REPO in $REPOLIST; do for PACKAGE in $DANGEROUS_PACKAGES; do /bin/grep "$PACKAGE" /mnt/data2/home/build/packages/logs/build2test/$DIST.$REPO.$DATE.log &> /dev/null