Jenkins build email notification by parsing log

alertingbuild-serverJenkins

I am using Jenkins to deploy in multiple servers. There are 4 backend servers are running. I have a script called deploy.sh in each server. At the time of deployment, Jenkins create a ssh session and run the deploy.sh script in each server one by one. But, sometimes it shows error in build console log "Errno : can not allocate memory" for few servers and then move to the next servers. I am looking for a solution, which will send me an email whenever there is a "error" keyword in the Jenkins log.

I found this link :- https://wiki.jenkins.io/display/JENKINS/Log+Parser+Plugin

But, it doesn't provide email notification and I am looking for a better solution.

Best Answer

In addition to Log+Parser+Plugin, you can use the Mailer plugin to send a mail notification when build is failed or unstable ( https://wiki.jenkins.io/display/JENKINS/Mailer ).

  • Install it from the plugins management
  • Setup the admin mail ( Configure System > Jenkins Location )
  • Fill in the smtp server configuration. ( Configure System > E-mail Notification )

Note: You can use any smtp server including google smtp if do not have. Many tutorials are availble for using google smtp as a relay. You can test before saving the configuration

  • Use Log Parser Plugin to mark the job as failed or unstable when error occurs
  • Finally configure your job to send you a notification when the build is marked as failed ( Post-build Actions > E-mail Notifications > Fill in the recipient field and check "Send e-mail for every unstable build" )

Hope this will helps!

Related Topic