Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hudson/Jenkins notification only on consecutive failures

I am using Jenkins for running Selenium tests in a monitoring way. The failures are often a temporary phenomenon (timeouts etc.). I escalate projects' execution upon a failure with Naginator plugin and the next build usually passes.

Thus, I am looking for a possibility to use a failure count which would enable sending a notification only when test fails n consecutive times. Do you have any idea how can one do it?

like image 513
datka Avatar asked Feb 23 '23 19:02

datka


1 Answers

Daniel, I believe your best bet is to script it yourself. I had a similar problem, and came up with a three-line solution on my own without any experience with Java/Groovy.

First off, you need a way to determine that a build has failed. See my problem for the solution.

Second, you need to store the number of failed builds somewhere. The file in the project workspace is the obvious location. Use this snippet as a base:

def f = new File(manager.build.getWorkspace().getRemote() + '/GroovyFailedBuildsCount.txt')
f.createNewFile()
f.write(text)

And third, you need to send an email. Off the top of my head you could mark the first failed builds as unstable, and when the limit is reached, mark the build as failed, and have the email-ext plugin to send email notifications only on failed builds.

Groovy getting started guide has been a great help for me.

like image 65
Vladimir Sinenko Avatar answered Mar 03 '23 23:03

Vladimir Sinenko