From 5714ce580b51c756ad794640585b9a243051877b Mon Sep 17 00:00:00 2001 From: varac Date: Wed, 15 Apr 2015 19:24:43 +0000 Subject: restructured the failure mails so they work correctly again --- leap-platform-test | 56 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/leap-platform-test b/leap-platform-test index fd1aa01..40b482d 100755 --- a/leap-platform-test +++ b/leap-platform-test @@ -161,6 +161,32 @@ deploy() { echo "Deploying \"$vm\" on $( date )"|tee -a "$LOG1" "$LOG2" $LEAP_CMD $OPTS -v 2 deploy "$vm" 2>&1 | ts | tee -a "$LOG1" "$LOG2" | egrep -v "$FILTER_ALL" | tee -a "$ERRLOG1" "$ERRLOG2" > /dev/null + + # send an host-specific error mail on deploy failures + if [ -s "$ERRLOG1" ] + then + touch "$deploy_failure" + versions=$( versions ) + subj="WARNING - \"leap deploy\" of platform $PLATFORM_BRANCH branch on \"$vm\" had errors !" + echo "$( date ): $msg" | tee -a "$LOG1" "$LOG2" "$ERRLOG2" + echo + msg="Output of error log below:\n\n$( cat "$ERRLOG1" ) \n\n" + msg="${msg}-------------------------------------------------------------------\n\n" + msg="${msg}error log: ${ERRLOG1}\n" + msg="${msg}comlete log: ${LOG2}\n\n" + + msg="${msg}Tested on $( date ) on \"$vm\" with following versions/git commit IDs: \n\n$versions" + + cat "$ERRLOG1" + + if [ "$MAIL_TO" != '' ]; then + echo "Sending this mail to $MAIL_TO:" + sendemail -f "$MAIL_FROM" -t "$MAIL_TO" -o tls=no -m "${msg}" -u "${subj}" + fi + else + echo "Deploy to $vm on $( date ) went fine."| tee -a "$LOG1" "$LOG2" + rm "$ERRLOG1" + fi done } @@ -179,31 +205,11 @@ log_start() { } deploy_failure_email() { - versions=$( versions ) - if [ -s "$ERRLOG1" ] - then - touch "$deploy_failure" - subj="WARNING - \"leap deploy\" of platform $PLATFORM_BRANCH branch on \"$vm\" had errors !" - echo "$( date ): $msg" | tee -a "$LOG1" "$LOG2" "$ERRLOG2" - echo - msg="Output of error log below:\n\n$( cat "$ERRLOG1" ) \n\n" - msg="${msg}-------------------------------------------------------------------\n\n" - msg="${msg}error log: ${ERRLOG1}\n" - msg="${msg}comlete log: ${LOG2}\n\n" - - msg="${msg}Tested on $( date ) on \"$vm\" with following versions/git commit IDs: \n\n$versions" - - cat "$ERRLOG1" - - if [ "$MAIL_TO" != '' ]; then - echo "Sending this mail to $MAIL_TO:" - sendemail -f "$MAIL_FROM" -t "$MAIL_TO" -o tls=no -m "${msg}" -u "${subj}" - fi - - elif [ ! -e "$deploy_failure" -a -n "$MAIL_TO" ] + # only send out a mail on success, because there are mails send out + # for every hosts that has deploy errors anyway + if [ ! -e "$deploy_failure" -a -n "$MAIL_TO" ] then - echo "Deploy to $vm on $( date ) went fine."| tee -a "$LOG1" "$LOG2" - rm "$ERRLOG1" + versions=$( versions ) subj="OK - \"leap deploy\" of platform $PLATFORM_BRANCH branch went fine." msg="Tested on $( date ) on these nodes: \"$nodes\"\nwith following versions/git commit IDs: \n\n$versions" @@ -272,7 +278,7 @@ init_deploy() { wait # send mail if deployment fails - deploy_failure_email + deploy_failure_email # run tests run_tests -- cgit v1.2.3