Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?
like image 852
Mike Chaliy Avatar asked May 01 '13 09:05

Mike Chaliy


People also ask

How do I add an HTML file to Jenkins workspace?

In your jobs (that generates the html files) go to configure -> Go to the post build section -> add a post build operation -> Archive the artifacts. Indicate the **/*. html files or just the name of the file you want to upload to the master and save.


2 Answers

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.

like image 100
Mike Chaliy Avatar answered Nov 07 '22 23:11

Mike Chaliy


Easy way to include the html file to email content is to add below line in the default content = ${FILE, path="yourfilename.html"}

this works for me in jenkins email ext plugin

like image 33
Chetan Kabra Avatar answered Nov 08 '22 00:11

Chetan Kabra