How to customize the email based on attachments?

146 views
Skip to first unread message

jsel...@gmail.com

unread,
Dec 9, 2016, 12:25:14 PM12/9/16
to Jenkins Users
Hello Friends,

I am new to Jenkins and configuring a job to run my automated selenium tests and have a need to send the email based on my build result and attachments.


Current Scenario - After my test run , i am attaching an .xml file and screenshots to the email notification. 


Content Type : Default Content Type
Default Subject : Smoke Test build results
Default Content : Attached is the html report for smoke tests and screen shots of failed tests.
Attachments:xxxx/target/surefire-reports/emailable-report.html,xxxxxt/target/surefire-reports/screenshots/*.png


My requirements : 

1. If there is attachment and no screen shots , i need default content to be and only attachment location.

Default Content : Attached is the html report for smoke tests 
Attachments:xxxx/target/surefire-reports/emailable-report.html,xxxxxt/target/surefire-reports/screenshots/*.png111


2. If there is no attachement and screenshots , default content should be 

Default Content : Configuration issues , attachment missing.




Any help is appreciated. 

Thanks
Jyo

Rachel Moreno

unread,
Dec 11, 2016, 4:12:42 PM12/11/16
to Jenkins Users
Hi Jyo,

If you install Email-ext plugin you'll have this section available when adding an Editable Email Notification in a job (Advanced settings):

Pre-send Script

This script will be run prior to sending the email to allow modifying the email before sending. The MimeMessage variable is "msg," the build is also available as "build" and a logger is available as "logger."

You may also cancel sending the email by setting the boolean variable "cancel" to true.


I hope be useful.

Best regards,
Rachel
Reply all
Reply to author
Forward
0 new messages