How to Mail Reports Through Jenkins | Configuring Email Notifications
This bit focuses on how to mail reports through Jenkins. We will see how to configure email notifications so that every time you run a job, emails get sent out to your team. Wouldn’t that be great?
Jenkins makes a lot of things easy. Not only does it provide a platform to run a build without getting into the technical aspects of it but it also ensures a proper completion of a project cycle which basically ends with you sending out a report to your peers. This is where our How to Mail Reports through Jenkins tutorial will come into the picture.
We are going to make use of the Editable Email Notification plugin in order to achieve this.
Let’s just quickly see how to mail reports through Jenkins using a step by step tutorial.
Steps on How to Mail Reports Through Jenkins
Step 1: The first step is to open Jenkins of course and navigate to your dashboard where you will have the Manage Jenkins option. Click on it.
Step 2: In the next screen scroll down to the part that reads “Manage Plugins”.
Step 3: Click on the “Available” tab and then on the Filter textbox to check if the Email Extension Plugin is present or not.
NOTE: In case you don’t find it there, check the “Installed” Tab to see if it is already installed on your Jenkins.
Step 4: Once you find it click on Install without restart.
Once the installation finishes, the plugin will basically be creating a separate box in your Post-Build Actions section that you can leverage to use all the generic mail functionality.
Step 5: Navigate to your project from your Dashboard. Then click on Configure.
Post Build Actions
Step 6: In the next screen click on the Post-build Actions tab. Or you can simply scroll down to the bottom of the screen.
Step 7: In the Post-build Actions section click on “Add post-build action” dropdown.
It will flare a dropdown of options.
Step 8: Look for the option that says Editable Email Notification. When you find it just click on it:
On clicking on it you will notice a new plugin box being displayed in the Post-build actions section. It might look something like this:
Step 9: Click on Advanced Settings…
Doing so will open some more textboxes. Triggers are nothing but instances where you wish to send out the email.
Step 10: Click on Add Trigger…
Step 11: Select when you wish to send out the report. I want the report after build so I am going to select Script – After build.
Step 12: Click on Advanced… button located in the Script – After Build section.
Notice every aspect of the plugin. That’s the place from where you can define who to send the emails to, what to add as the content, what should be the Subject etc. Go ahead and play around with it.
I am gonna just leave everything as is, except the recipient list, of course, where I will put an email ID just to check if reports are indeed being sent out.
NOTE: As mentioned in the image above, you can add as many emails as you want. Just separate them by commas.
In the subject or default content textboxes you can customize things with your own custom messages. I am just gonna leave things blank and move on to the part that matters the most to me right now – the Attachments section.
Attachment of Reports
Step 9: Navigate back to your Workspace and check what’s the path of your reports.
In my case here, the path is basically:
where all my .xlsx files are located.
If you need all the .xlsx files, you can simply mention it like this:
which basically means all the files that have the extension .xlsx.
Step 10: I am gonna just go ahead and add the above in the attachments textbox:
You can provide your very own location of the report here. Just make sure the extension you want is right. (In case of Extent Report provide .html etc.)
NOTE: If you do not want to attach a build log to your mail and just want the report part you can select “Do Not Attach Build Log” option from the dropdown of Attach Build Log like this:
Step 12: Once done you can simply click on Apply then Save to proceed back to your project.
Time to run it.
Execution of your Job
Next screen will take you to your project once again from where you can run your job to check whether or not the reports are being generated.
Step 13: Click on Build with Parameters which will take you to the part from where you can enter your parameters.
Step 14: Once ready click on Build to start the job.
NOTE: Of course this will be different for your project.
Step 15: The build will basically start with that. You can choose to check out the build information by clicking here:
Step 16: Navigating to the next page you can check out the console output by clicking on Console Output.
Now we wait….
For the execution of our job.
Alright with that the report might have been sent out to my email ID. I will just go and quickly check!
Checking for the report now. Yep! There!
Now that you know How to Mail Reports Through Jenkins start mailing the reports in an automated fashion.
Check out more cool stuff from DITD.