How to include content of the html file to template of the jenkins email-ext?

Mike Chaliy picture Mike Chaliy · May 1, 2013 · Viewed 12k times · Source

I am using Jenkins and email-ext to send build notifications. Build produces small custom report stored as simple HTML in out directory. Right now I can easy attach this report to the email, but what I want is to have this report rendered to the email body itself. I know that I can write my own jelly template, but this requires access to the build server(to install jelly script), I want to avoid this too. So my questions are:

  1. Can I include content of the arbitrary file(generated during build) to Content field of the Email-Ext plugin?
  2. If I cannot, what is most easy way to send such report in Jenkins?

Answer

Mike Chaliy picture Mike Chaliy · May 1, 2013

It looks like most easy way is to use 'Pre-send Script' of the Email-ext

Script looks like this:

def reportPath = build.getWorkspace().child("HealthTestResults.html")
msg.setContent(reportPath.readToString(), "text/html");

It renders content of the HealthTestResults.html located in the root of the workspace just as body of the message.