Triggering Jenkins builds By Email

Triggering Jenkins builds By Email


In this article, we are going to look at how we can automatically execute our Jenkins Job just by receiving an email in our mailbox this functionality is very much useful where we wanted to execute our build on remote machine or server where we don’t have any direct access to it.

Just imagine you are seating at your home or some restaurant and directly triggering your Jenkins build by just sending one email notification.

For this purpose, we need to use Poll Mailbox Trigger Plugin.

To know more about this plugin please click on this link.


The poll-mailbox-trigger is a Jenkins "build trigger" plugin, which allows a Job to poll an email inbox. When an unread email is found, that matches the configured criteria, it:
1.    marks the email as read, so that it is not reprocessed
2.    triggers a new job

To Setup Poll Mailbox plugin, we need to follow steps

1)    Go to Jenkinsร  Manage Jenkinsร Manage Pluginร Install Poll Mailbox Plugin.


2)    Now click on New item and Create New Jenkins Job.

3)    Under Build Trigger Section. Select the option of Poll Mailbox Trigger.


4)    Here we need to provide the details for the host, username, and password.
  AlsoClick on Advanced and under Advanced Email Properties, we can select any configurations. Like build will get trigger if subject contains Jenkins Build Trigger.






  Few Sample Configurations are



5)    After this Click on Test Connection and validate your settings.

6)   Click on Apply and Save Options.

7) Now whenever we receive mail in our inbox which contains subject as Jenkins Build Trigger, it will automatically trigger our Jenkins job.


 If you are using gmail option please make sure to enable a less secure option as enabled in your mailbox.




SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
November 7, 2019 at 7:35 PM

Hi,
Thanks for the Article.Its Really Useful.I followed the same steps in free style project it was worked for me.But when i followed the same step i cant trigger build in pipeline project.Can you help me if possible.
Thanks...

Reply
avatar
shirly
November 19, 2021 at 6:02 AM

Can you help me how to download email attachments in Jenkins using the poll mailbox plugin

Reply
avatar