Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display HTML using Jenkins email ext plugin

I am new to Jenkins and I'm trying to attach a HTML file to the body of an email that is created on one of my slaves. I'm using the email-ext plugin but I'm not sure how to attach the HTML to the body - i.e. where does the HTML file have to be located, code to attach it?

like image 580
erman8 Avatar asked Nov 10 '13 18:11

erman8


People also ask

How do I use email extension plugin in Jenkins?

Click the 'Available' tab present at the top of the 'Manage Plugin' page. Type 'Notification' in the 'Filter' field displayed at the top-right side of the 'Manage Plugin' page. Click the checkbox next to the 'Email-ext plugin' option and 'Email-ext Template Plugin' option. Click the 'Install without restart' button.


2 Answers

I'm pretty sure someone here can come up with a more fancy solution, but I've seen (not been able to get it to work as I would like :-( ) that this can be done using a groovy template.

It should be as simple as placing the following snippet inside the body of your e-mail content:${SCRIPT, template="groovy-html.template"}

And then modifying the content of the groovy-html.template file to suit your needs. I'd recommend starting out with the template already present with your installation and then modifying it as you go along.

You might also need to include the groovy plugin but I'm not sure about that.

like image 40
llykke Avatar answered Nov 15 '22 07:11

llykke


I would suggest also just plugging your HTML code straight into the email trigger section.

heres an example of what i'm using:

<html>
<body>
Hi there $DOTCI_PUSHER
<br>
<br>
You are receiving this email because Build $BUILD_NUMBER has been set to: $BUILD_STATUS
<br>
<br>
<u>Execution Results :</u><br>
Avg : ${BUILD_LOG_REGEX, regex="Avg:", showTruncatedLines=false}<br>
Min : ${BUILD_LOG_REGEX, regex="Min:", showTruncatedLines=false}<br>
Max : ${BUILD_LOG_REGEX, regex="Max:", showTruncatedLines=false}<br>
Errors : ${BUILD_LOG_REGEX, regex="Err:", showTruncatedLines=false}<br>
<br>
Build URL : $BUILD_URL
<br>
<br>
Console Output: <br>
<pre>${BUILD_LOG, maxLines=20}</pre>
</body>
</html>
like image 165
Jordan Avatar answered Nov 15 '22 09:11

Jordan