Jenkins send email notification only if last N builds have failed (not per run) - Editable Email Notification
Asked Answered
B

2

5

Jenkins 1.6 - 2.x

I have a job which runs every minute or 2 and sometimes the build fails and the next builds passes. For build failures, I'm using Editable Email Notification plugin in Jenkins.

Either using this plugin or any other plugin/way, can I somehow configure Jenkins job to send me a failed build notification ONLY if the last 3 consecutive builds have failed? It's no fun to watch these builds fail and then succeed in the next run so I'm trying to reduce the frequency of such failure notifications OR make it more intelligent.

I have mentioned a comment for a new feature request here: https://wiki.jenkins.io/display/JENKINS/Email-ext+Template+Plugin?focusedCommentId=132940540#comment-132940540 but looking if someone have tried / achieved something similar.

Bayreuth answered 30/6, 2017 at 21:38 Comment(0)
A
7

Email-ext plugin has a Nth failure trigger (Failure - X) but you should really do something about the random failures

Anadem answered 1/7, 2017 at 0:31 Comment(5)
Agree @David van Laatum. I read yesterday that within pipeline plugin (groovy code), retry / timeout can be used (or wrapped to create this behavior) if I can do that at the sub-step level (which is failing i.e. "gulp" build in my case). Under "Timeouts, retries and more" here: github.com/jenkinsci/pipeline-model-definition-plugin/wiki/…. I'll look into the root cause to fix the issue permanently but was curious to know if such solution existed. Thanks for the Nth failure trigger hint.Bayreuth
It would also be great if we can have that Nth failure trigger setting available and configured at Jenkins Global Config settings level (so that a user can control default settings for this feature Globally for all jobs without requiring everyone to change Failure Any -> Failure Still or Failure - 2nd).Bayreuth
happy to accept a pull request if you feel like implementing ;) also please accept my answerAnadem
For those who are curious, it doesn't look like this feature is available in the pipeline script: github.com/jenkinsci/email-ext-plugin/pull/…Rowe
Some jobs are affected by occasional network errors you can't control. Instead of wrapping steps in complex retry logic it seems right to notify only after multiple failures.Enchanting
A
0

As it's mentioned in accepted answer - Email-ext have that feature.

I recently had to use "Failure - X", but message destination had to be Slack channel - not email. In such a situation, you can install on Slack plugin, which generate special email address for given Slack channel. It will allow you to send emails to Slack. Then you use Email-ext on Jenkins so you'll get slack msg after X failed builds.

Alyce answered 23/11, 2017 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.