Email notification in jenkins based on a script output

user2946704 picture user2946704 · Apr 10, 2014 · Viewed 19.1k times · Source

I am stuck at a point where I run a perl script through jenkins and I want a conditional email notification to be sent.

For eg .. if at the end of script the value of a certain variable is > 1 then send the email notification else dont send

Can anybody help me with this ? or knows a better way to do this ?

Answer

Slav picture Slav · Apr 10, 2014

I haven't any of this, however:

There is an Any Build Step plugin. Among other things, it allows post-build actions to be executed as build steps. In theory, this should allow you to execute "Editable Email Notification" post-build step as a build step. This is the biggest wildcard in this solution. Try this first. I don't know if the email notification will work properly when done before the Jenkins' "build cycle" of a job is complete.

Next, there is Conditional Build Step plugin. It allows you to execute a build step based on various conditions.

If you were able to trigger email in the middle of the build cycle with "Any Build Step" plugin, you should be able to wrap it with the "Conditional Build Step" plugin to be executed conditionally.

Let me know if this actually works