user3780647
user3780647

Reputation: 159

Jenkins : sending email notification when starting a build

In Jenkins, Is there a way to send a mail when starting a build. I know there is a post-build email notification which sends mail to the given recipients after a successful or failure build. Similarly i am expecting something like pre build notification.

Also is there a conditional email like if username == null send to [email protected] else send it to requestor.

Tried : couple of plugins but didn't help much as they were post-build plugins

Upvotes: 12

Views: 21161

Answers (3)

zedv
zedv

Reputation: 1469

  1. Install the Email-ext plugin: https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

Notice that a post build action will solve your problem even though what you intend is to send an e-mail before the build.

  1. After that, go to the job configuration and "Add Post Build Action" > "Editable Email Notification"

  2. Press Avanced Settings: Press advanced settings...

  3. Now, at Triggers, just add a new trigger and choose "Before Build" enter image description here

For the second part, the solution is to put the recipient list in an environment variable (for example, a string parameter called EMAIL_RECIPIENT) and then use that in the editable email notification recipients list box as ${EMAIL_RECIPIENT}.

Upvotes: 17

Tuan
Tuan

Reputation: 2363

You can try the Extend Email-ext, it has the Before build in the Triggers section.

https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

Upvotes: 0

Mayur Nagekar
Mayur Nagekar

Reputation: 821

If you have sendmail configured, just use the "Execute shell" section and write the code to send mails before the build starts.

Upvotes: 0

Related Questions