Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins : sending email notification when starting a build

Tags:

jenkins

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

like image 204
user3780647 Avatar asked Nov 10 '15 23:11

user3780647


People also ask

How Jenkins can send email when build pass or failed?

Select “Configure”. Select “Add post-build action” and Click “E-Mail Notification”. Enter your recipients mail address and select first option “Send e-mail for every unstable build”. Click “Save” button.

How do I send an email after every build in Jenkins?

Click on Manage Jenkins from Left Pane. Click on Configure System under the System configuration. Under the Email Notification. Put the SMTP server as smtp.gmail.com in SMTP server field.

Does Jenkins have notification mechanism?

Jenkins comes with an out of box facility to add an email notification for a build project. Step 1 − Configuring an SMTP server. Goto Manage Jenkins → Configure System. Go to the E-mail notification section and enter the required SMTP server and user email-suffix details.


1 Answers

  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}.

like image 176
zedv Avatar answered Nov 10 '22 13:11

zedv