We have automated ant process which runs every day to check health check of particular component, this has been configured through crontab. It failed to complete the process and hung in between, so there is no mail generated. To close this hole, have written small script which will check the log file and look for 'BUILD SUCCESSFUL' if it is not found error mail will be generated. This is configured to run 1 hour after the verification script. This works well :)
Here is the sample script which i used
ErrorCheck.sh:
#!/bin/ksh
log_file=$1
subject=$2
shift
shift
mailaddrs=$*
## checks for (BUILD SUCCESSFUL). If not present, sends email.
grep_result=`grep -c "BUILD SUCCESSFUL" $log_file`
if [ "$grep_result" = "1" ]
then
echo "NO PROBLEM"
else
echo "PROBLEM"
mailx -s"$subject" $mailaddrs < $log_file
fi
How to Execute:
./ErrorCheck.sh {logfilename} {Email subject} {email addresses separated by space}
./ErrorCheck.sh junitresult.log "Dev Test failed" test@test.com test1@test.com
Thursday, January 3, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment