email-ext-plugin doesn't translate any variable!!!!

36 views
Skip to first unread message

Antonio Hernandez

unread,
Jun 28, 2016, 6:20:49 AM6/28/16
to Jenkins Users
hi there!,

I'm very confused when i'm trying to send an email with all changes and also with the console output.

To get all the information together i'm using:

one script writing all the changes in a file like this:

| Author: [     ] | Subject: [bugfix/XXX-YYY..] | When: [2016-06-23] | Commit: [5b20a12] |
|-------------------------------------------------------------------------------------------------------|
 XXX/runme.groovy | 1 +
 1 file changed, 1 insertion(+)


and also i installed the parser Console output configured to highlighing only errors (in red) and info (in blue), something like this:

-------------------------------
TC04 --> started!
---------> Step 01 OK!
---------> Step 02 KO :(


And finally i have a template to put all together, here is the example:


<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>

<TABLE>
  <TR><TD align="right"><IMG SRC="${rooturl}static/e59dfe28/images/32x32/<%= build.result.toString() == 'SUCCESS' ? "blue.gif" : build.result.toString() == 'FAILURE' ? 'red.gif' : 'yellow.gif' %>" />
  </TD><TD valign="center"><B style="font-size: 200%;">BUILD ${build.result}</B></TD></TR>
  <TR><TD>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:</TD><TD>${it.timestampString}</TD></TR>
  <TR><TD>Duration:</TD><TD>${build.durationString}</TD></TR>
  <TR><TD>Cause:</TD><TD><% build.causes.each() { cause -> %> ${cause.shortDescription} <%  } %></TD></TR>
</TABLE>
<BR/>

<!-- CHANGE SET -->
<% def changeSet = build.changeSet
if(changeSet != null) {
def hadChanges = false %>
<TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR>
<% changeSet.each() { cs ->
hadChanges = true %>
      <TR>
        <TD colspan="2" class="bg2">&nbsp;&nbsp;Revision <B><%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision : 
        cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %></B> by
          <B><%= cs.author %>: </B>
          <B>(${cs.msgAnnotated})</B>
         </TD>
      </TR>
<% cs.affectedFiles.each() { p -> %>
        <TR>
          <TD width="10%">&nbsp;&nbsp;${p.editType.name}</TD>
          <TD>${p.path}</TD>
        </TR>
<% }
}
if(!hadChanges) { %>
        <TR><TD colspan="2">No Changes</TD></TR>
<% } %>
  </TABLE>
<BR/>
<% } %>

<!-- ARTIFACTS -->
<% def artifacts = build.artifacts
if(artifacts != null && artifacts.size() > 0) { %>
  <TABLE width="100%">
    <TR><TD class="bg1"><B>BUILD ARTIFACTS</B></TD></TR>
    <TR>
      <TD>
<% artifacts.each() { f -> %>
       <li>
         <a href="${rooturl}${build.url}artifact/${f}">${f}</a>
       </li>
<% } %>
      </TD>
    </TR>
  </TABLE>
<BR/>  
<% } %>

.............

--------
When i received the mail no variable is translated:


" />BUILD ${build.result}
URL${rooturl}${build.url}
Project:${project.name}
Date:${it.timestampString}
Duration:${build.durationString}
Cause:<% build.causes.each() { cause -> %> ${cause.shortDescription} <% } %>

<% def changeSet = build.changeSet if(changeSet != null) { def hadChanges = false %>
CHANGES
<% changeSet.each() { cs -> hadChanges = true %>
  Revision <%= cs.metaClass.hasProperty('commitId') ? cs.commitId : cs.metaClass.hasProperty('revision') ? cs.revision : cs.metaClass.hasProperty('changeNumber') ? cs.changeNumber : "" %> by <%= cs.author %>:(${cs.msgAnnotated})



--------

How can i get the email with all variables translated?
How can i mix my changes file, my parse output log in a rich format mail ?


any help will be appreciated so much











Slide

unread,
Jun 28, 2016, 8:36:04 AM6/28/16
to Jenkins Users

How are you specifying the content?


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7c57e877-2ee5-4d87-965d-884fef28351c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Hernandez

unread,
Jun 28, 2016, 9:33:37 AM6/28/16
to Jenkins Users
Hi Slide,
that's the problem i have, i don't know how to handle it. 
I have all the ingredients but i don´t know how to put all together in a rich format html.....
I'm desperate with that because i've never developed in html
Thanks again,

Slide

unread,
Jun 28, 2016, 9:40:50 AM6/28/16
to Jenkins Users
You would need to either install the config file provider plugin and create a new Email Ext Groovy Template, or put the template on the file system in JENKINS_HOME/email-templates. Then you could use the SCRIPT token to specify the template in the content area of the post-build setup. ${SCRIPT, template="file.template"} or for managed files ${SCRIPT, template="managed:Name of Managed Item"}

Antonio Hernandez

unread,
Jun 28, 2016, 11:58:40 AM6/28/16
to Jenkins Users
Hi Slide, 
I really appreciate your help but i already did everything except the config file provider...



Is it must be the problem with the variables?
Thanks again

Slide

unread,
Jun 28, 2016, 12:02:00 PM6/28/16
to Jenkins Users
No, you used JELLY_SCRIPT, which only works if you are using Jelly templates. The code you showed looked like groovy. If you look at my last reply, I said use SCRIPT, not JELLY_SCRIPT.

Reply all
Reply to author
Forward
0 new messages