RE: Jenkins email ext plugin -To Send the file contents as mail

3,529 views
Skip to first unread message

Alex Earl

unread,
Nov 14, 2012, 11:42:44 AM11/14/12
to hari haran, jenkins...@googlegroups.com
message body
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_375_26436934.1352907687514"

------=_Part_375_26436934.1352907687514
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit

You most likely can't send an iframe correctly in an email. I'm
guessing most email clients will block that.

Sent from my Windows Phone
From: hari haran
Sent: 11/14/2012 7:41 AM
To: jenkins...@googlegroups.com
Subject: Jenkins email ext plugin -To Send the file contents as mail
message body
Hi All,

I added email-ext to my jenkins to send emails about test results . I want
to send a html file content as email message body.

I tried changing "Content Type" as "HTML (text/html)" and i gave an iframe
in "Default Content" field. But its not able to pick the iframe. Here is
the code

Code Used In "Default Content"

$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:

<br /><iframe src="http://www.w3schools.com" width="200"
height="200"><p>you should have seen my other page here, but something
broke.</p></iframe>

<br />Check console output at $BUILD_URL to view the results.

<br />Failed tests: ${FAILED_TESTS}

Please someone tell me how "Default Content" should be changed so that its
able to pick the HTML file contents and display it as message body

------=_Part_375_26436934.1352907687514
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html><head><meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Cont=
ent-Type"></head><body><div><div style=3D"font-family: Calibri,sans-serif; =
font-size: 11pt;">You most likely can't send an iframe correctly in an emai=
l. I'm guessing most email clients will block that.<br><br>Sent from my Win=
dows Phone<br></div></div><hr><span style=3D"font-family: Tahoma,sans-serif=
; font-size: 10pt; font-weight: bold;">From: </span><span style=3D"font-fam=
ily: Tahoma,sans-serif; font-size: 10pt;">hari haran</span><br><span style=
=3D"font-family: Tahoma,sans-serif; font-size: 10pt; font-weight: bold;">Se=
nt: </span><span style=3D"font-family: Tahoma,sans-serif; font-size: 10pt;"=
>11/14/2012 7:41 AM</span><br><span style=3D"font-family: Tahoma,sans-serif=
; font-size: 10pt; font-weight: bold;">To: </span><span style=3D"font-famil=
y: Tahoma,sans-serif; font-size: 10pt;">jenkins...@googlegroups.com</s=
pan><br><span style=3D"font-family: Tahoma,sans-serif; font-size: 10pt; fon=
t-weight: bold;">Subject: </span><span style=3D"font-family: Tahoma,sans-se=
rif; font-size: 10pt;">Jenkins email ext plugin -To Send the file contents =
as mail message body</span><br><br></body></html>Hi All,<br><br>I added ema=
il-ext to my jenkins to send emails about test results . I want to send a h=
tml file content as email message body.<br><br>I tried changing "Content Ty=
pe" as "HTML (text/html)" and i gave an iframe in "Default Content" field. =
But its not able to pick the iframe. Here is the code<br><br>Code Used In "=
Default Content"<br><br>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STAT=
US:<br><br>&lt;br /&gt;&lt;iframe src=3D"http://www.w3schools.com" width=3D=
"200" height=3D"200"&gt;&lt;p&gt;you should have seen my other page here, b=
ut something broke.&lt;/p&gt;&lt;/iframe&gt;<br><br>&lt;br /&gt;Check conso=
le output at $BUILD_URL to view the results.<br><br>&lt;br /&gt;Failed test=
s: ${FAILED_TESTS}<br><br>Please someone&nbsp; tell me how "Default Content=
" should be changed so that its able to pick&nbsp; the HTML file contents a=
nd display it as message body<br>
------=_Part_375_26436934.1352907687514--

Marek Gimza

unread,
Nov 14, 2012, 11:50:14 AM11/14/12
to jenkins...@googlegroups.com
I think that the iframe would work in a jelly script/
There should be enough documentation in the "Email Ext" plugin's TWIKI page about jelly scripts.

My quick summary of what could be done:


1. Create the subdir $JENKINS_HOME/email-templates
------------------------------------------------------------------------

2. In that subdir create a file called test.jelly.
Its contents would be something similar to:


<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<STYLE>
BODY, TABLE, TD, TH, P {
  font-family:Verdana,Helvetica,sans serif;
  font-size:11px;
  color:black;
}
h1 { color:black; }
h2 { color:black; }
h3 { color:black; }
TD.bg1 { color:white; background-color:#0000C0; font-size:120% }
TD.bg2 { color:white; background-color:#4040FF; font-size:110% }
TD.bg3 { color:white; background-color:#8080FF; }
TD.test_passed { color:blue; }
TD.test_failed { color:red; }
TD.console { font-family:Courier New; }
</STYLE>
<BODY>
<j:set var="spc" value="&amp;nbsp;&amp;nbsp;" />

<!-- GENERAL INFO -->



$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:

<br /><iframe src="http://www.w3schools.com" width="200"
height="200"><p>you should have seen my other page here, but something
broke.</p></iframe>

<br />Check console output at $BUILD_URL to view the results.

<br />Failed tests: ${FAILED_TESTS}

<!-- here is some extra stuff that could be used -->
<TABLE>
  <TR><TD align="right">
    <j:choose>
      <j:when test="${build.result=='SUCCESS'}">
        <IMG SRC="${rooturl}static/e59dfe28/images/32x32/blue.gif" />
      </j:when>
          <j:when test="${build.result=='FAILURE'}">
        <IMG SRC="${rooturl}static/e59dfe28/images/32x32/red.gif" />
      </j:when>
      <j:otherwise>
        <IMG SRC="${rooturl}static/e59dfe28/images/32x32/yellow.gif" />
      </j:otherwise>
    </j:choose>
  </TD><TD valign="center"><B style="font-size: 200%;">BUILD ${build.result}</B></TD></TR>
  <TR><TD>Build URL</TD><TD><A href="${rooturl}${build.url}">${rooturl}${build.url}</A></TD></TR>
  <TR><TD>Project:</TD><TD>${project.name}</TD></TR>
  <TR><TD>Date of build:</TD><TD>${it.timestampString}</TD></TR>
  <TR><TD>Build duration:</TD><TD>${build.durationString}</TD></TR>
</TABLE>
<BR/>

</BODY>
</j:jelly>

------------------------------------------------------------------------
3. In the JOB, add the following line in the email's DEFAULT_CONTENT to parse/use the jelly file:

${JELLY_SCRIPT,template="test"}

------------------------------------------------------------------------

I hope that this may help,
Mgimza

hari haran

unread,
Nov 19, 2012, 12:18:38 PM11/19/12
to jenkins...@googlegroups.com, hari haran
iframe is not working on jelly script.
 
I tried using the following syntax in my jelly file to read the contents of HTML file and send it as email message body but its not working.

<j:include file="C:/jenkins/jobs/ServiceMavenProject/builds/${build.id}/cucumber-html-reports/feature-overview.html" />

Slide

unread,
Nov 19, 2012, 12:21:39 PM11/19/12
to jenkins...@googlegroups.com, hari haran
I don't think any respectable email client would allow you to include an iframe in an email. It's too much of a security risk.
Reply all
Reply to author
Forward
0 new messages