monitor job failures in a Jenkins and Email alert - jenkins

I need to write a script to monitor job failures in a Jenkins farm and send an email with a report of the top 5 unstable jobs in the farm.
How can do it?
Is there any plugin available for this requirement ?

Jenkins mailer plugin can send mails if a build fails. Did you try that ?
link

Related

Email no longer sent after jenkins job execution

On a Ubuntu, I have a Jenkins service setup with Email-EXT plugin, where I have setup jobs executed regularly, and emails are being sent after the job execution. But just recently, I no longer receive any emails after the job execution.
Details:
In each job execution "console output", it is said that Email has been triggered.
And I was able to use the "Test configuration by sending test e-mail"
on Jenkins/"configure system" page" to send out the testing email.
Based on my company rule, I had the password changed just recently.
And I did the some update on jenkins/configure page as well.
jenkins version 2.176.1
EMAIL-EXT plugin version: 2.69
So what could be wrong for not receiving emails ????
In my case, there is nothing wrong with the jenkins side settings. I have switched the smtp server to user the gmail one, and it works. It must be some policy change on my company smtp server side.
BTW, to turn on the debug mode of the trigger gives some direction to my case.

Jenkins Slack integration, but can't find post-build action

I want to use the Slack plugin in Jenkins to ping notifications to a Slack channel.
Jenkins says success when I test the connection, and I saw that connect was successful.
And after that, I need to add to Jenkins job configurations and add a post-build action on each job that you wish to ping the slack channel.
But I can't find post-build action in Job's configure.
Jenkins has version 2.121.3.
What kind of job configuration are you using ? Freestyle ? Multibranch ? Pipeline ? It's likely that the post-build actions will not appear for every kind of Jenkins job/project.
If you create a new job (New Item > Freestyle project), you should see the option at the end.

Jenkins e-mail notification only for first failing commit

For my Jenkins job I would like to have Jenkins send e-mails under two conditions:
The build was fine before, but now it fails.
The build failed before, but now it is fine.
I do not want it to send e-mails for any additional failing builds between (1) and (2).
I would have expected that having the setting "Send e-mail for every unstable build" unchecked would prevent just that, but I receive e-mail for every single failed build.
How can I achieve my desired behavior? Is this a bug in Jenkins (2.121.2) or the Mailer plugin (1.21)?
There is a better plugin for sending emails on certain conditions on Jenkins plugin site: https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
Try finding Editable email in post-build actions or install it via Jenkins manage plugins options.
Below is a screenshot which is part of the Editable Email notification post-build task:

Get Failure reason from jenkins

Can we send mail only the failure reason from jenkins, when jenkins build is getting fail. I am using Email-ext plug-in , and using that plug-in i can able send only HTML report through Jenkins .
You are using the right plugin Email-ext plug-in you need to configure the global level settings for this plugin in Jenkins(setting up SMTP). Once you are done with is setup,Go to the job level settings in Jenkins and select the event as (send only on failure)
follow : https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

retrospectively switch on emails for Jenkins jobs

We have a Jenkins instance with over 250 jobs installed in it. Until recently corporate rules prevented us from configuring Jenkins to send emails for build failures etc.
We have now been given permission to configure Jenkins to connect to the corporate SMTP server and I have configured one job to send emails and all is working fine. Is there an automated way to enable emails for all jobs or do I have to go into the configuration for each job and manually enable it?
If not are there any plugins or shell scripts?
Configuration Slicing plugin (https://wiki.jenkins-ci.org/display/JENKINS/Configuration+Slicing+Plugin) can help in this situation.
Install this plugin, then go to Manage Jenkins -> Configuration Slicing -> E-mail Notification
Put email into the left column, all job names to the right column, then press Save.
Please note that it will change each job configuration and add E-mail publisher to them.

Resources