Jenkins Job to Send Email Notification on Every Execution.

We will create a basic Jenkins freestyle project to use the Extended Email Notification feature of Jenkins.

Note: This job will send an email on every build regardless of the success or failure of the build.

Step 1. Create a freestyle Job.

Create a freestyle project.

 

Step 2. Configure a build step.

✔  Select Execute shell option.

 

build-step-option

 

✔  Print something using the echo command.

 

execute-shell

 

Step 3. Configuring Email Notification step.

✔  Go to Add post-build action and select Editable Email Notification.

✔  Give any name in the “Project From” field. For ex. Jenkins

✔  Project Recipient List has the email you have mentioned while configuring Extended Email notification.

Step 4. Set the Email trigger.

✔  Click on the Advanced Settings… button to set the email trigger.

✔  Close the default trigger (Failure – Any) setting.

✔  Now Click on the Add Trigger Button and choose “Always”. You can explore other options as well.

✔  Apply and Save the configuration.

set-email-trigger

 

Step 5. Click on Build Now.

build-button

 

Step 6. Check the Console Output.

The Console Output has the all details regarding build, email, and trigger.

email-console

 

Step 7. Check the email.

The Recipient email will receive the email.

Assignment:

✔  Create a Jenkins job that should send an Email Notification only on success.

✔  Modify the above job to send console output as an attachment.