How to send email notification from Jenkins with TestNG Report?
1. If you don't how to configure Jenkins and run project then please refer http://seleniumbestpractices.blogspot.com/2018/08/how-to-run-selenium-project-from.html
2. start jenkins.war file to get started with Jenkins.
3. Go to http://localhost:8080 to open Jenkins.
Required Plugins
***********************
- Email Extension
- Email Extension Template Plugin
- TestNG Results
- Selenium HTML Report
Configuration for Sending Email
******************************************
- Go to Jenkins => Manage Jenkins => Configure System => Email Notification
- Enter "smtp.gmail.com" in the "SMTP Sever" edit field NOTE : we will take gmail as an example
- Click on "Advanced" and do the configuration as shown in the below image.
- Username and password need to be provided for the account from where you want to send the email notification.
- For testing purpose, check the "Test configuration by sending test e-mail" checkbox to validate whether email is sent successfully or not.
- Enter the email address of recipient and click on "Test Configuration" button.
- If you are able to see "Email was successfully sent" message then you will get to know that configuration is correct.
- If you see any error message then either configuration is not correct or you have to do the below steps to enable "Less secure app access"
- Navigate to https://myaccount.google.com/
- Click on "Security"
- Go to "Less secure app access" section and turn it on
- We are all set to send email Notification.
- Go to Jenkins Dashboard and create a new Job
- I have created a new project and named it as "VerifyEmailNotification". You can also create your own project
- Now Click on "Configure" displayed in the above image.
- Give Description of Project and select "Execute Batch Command" from Build drop down and enter any invalid command as shown in the below image as email will be sent for every unstable build. (If the build fails then only email notification will be sent)
- Select "E-mail Notification" from "Post-build Actions" and send the email address of the recipient and check "Send e-mail for every unstable build" as shown in below image.
- Click on "Save" to save the configuration.
- Click on "Build Now" to run the job and go to "Console Output" to check the result.
- Check the recipient mail to see the email sent from Jenkins.
Let's do the configuration to attach TestNG Report in the Email
==================================================
- Go to Jenkins => Manage Jenkins => Configure System => Extended Email Notification
- Enter "smtp.gmail.com" in the "SMTP Sever" edit field NOTE : we will take gmail as an example
- Click on "Advanced" and enter the details as shown in the below image.
- Click on "Save" to save the configuration.
- Navigate to Jenkins dashboard and create a new project. I have an existing project [Flight Reservation (POM)]
- If you don't how to configure Jenkins and run project then please refer http://seleniumbestpractices.blogspot.com/2018/08/how-to-run-selenium-project-from.html
- Click on Configure displayed in the above image.
- Select "Editable Email Notification" from "Post-build Actions"
- Click on "Advanced Settings..."
- Select "Always" from "Add Trigger" drop down.
- Click on "Advanced..." and do the configuration as shown in the below image.
- In the Content edit field, you have to give the path of emailable-report.html of TestNG.
- Click on "Save" to save the configuration.
- Now click on "Build Now" to start the execution.
- Go to "Console Output" to check the result.
- Check you the recipient mail to see the Test Execution report.
Great article with lots of useful information on Selenium Training in Chennai wonderful explanation on Selenium module.
ReplyDeleteSelenium Training Center in Chennai | Best Selenium Training in Chennai | Selenium Training Institute in Chennai
Very nice. Thanks a lot.
ReplyDeleteIam trying to attach the extent report to the email in the post build steps when i get the email, the email is in text form ,could you please suggest what to do?
ReplyDelete