We will create a basic Jenkins freestyle project to use the Extended Email Notification feature of Jenkins.
Step 1. Create a freestyle Job.
Create a freestyle project.
Step 2. Configure a build step.
✔ Select Execute shell option.
✔ Print something using the echo command.
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.
Step 5. Click on Build Now.
Step 6. Check the Console Output.
The Console Output has the all details regarding build, email, and trigger.
Step 7. Check the email.
The Recipient email will receive the email.
✔ Create a Jenkins job that should send an Email Notification only on success.
✔ Modify the above job to send console output as an attachment.