EmailExt 2.39

49 views
Skip to first unread message

dj44port

unread,
Jan 14, 2015, 11:57:20 AM1/14/15
to jenkins...@googlegroups.com
Updated Jenkins to 1.596, and update to EmailExt 2.39
And have the following dependencies installed
token-macro - 1.10
script-security - 1.12
mailer - 1.12

The issue is we have some custom email templates, when the email is sent
The logs for Jenkins and the error sent in the email are below.
Changed the name of the template being used to groovy-html.template
And the emails were sent successfully.
Why can't custom named templates be used anymore?

There are no errors in the Jenkins log
22:44:32 Checking if email needs to be generated
22:44:32 Email was triggered for: Success
22:44:32 Sending email for trigger: Success
22:44:32 NOT overriding default server settings, using Mailer to create session
22:44:32 messageContentType = text/html; charset=UTF-8
22:44:32 Adding recipients from project recipient list
22:44:32 Adding recipients from trigger recipient list
22:44:32 Successfully created MimeMessage

The email that gets sent has the following errors

Exception raised during template rendering: java.io.FileNotFoundException: /var/lib/jenkins/workspace/Product1 (Is a directory) java.io.IOException: java.io.FileNotFoundException: /var/lib/jenkins/workspace/Product1 (Is a directory) at hudson.remoting.FastPipedInputStream.read(FastPipedInputStream.java:169) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:282) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:324) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:176) at java.io.InputStreamReader.read(InputStreamReader.java:184) at java.io.Reader.read(Reader.java:140) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2001) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1980) at org.apache.commons.io.IOUtils.copy(IOUtils.java:1957) at org.apache.commons.io.IOUtils.copy(IOUtils.java:1907) at org.apache.commons.io.IOUtils.toString(IOUtils.java:778) at org.apache.commons.io.IOUtils.toString(IOUtils.java:759) at hudson.FilePath.readToString(FilePath.java:1842) at hudson.FilePath$readToString$0.call(Unknown Source) at SimpleTemplateScript12.run(SimpleTemplateScript12.groovy:29) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:165) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:177) at hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:216) at hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:85) at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:189) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:182) at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:233) at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:72) at hudson.plugins.emailext.ExtendedEmailPublisher.getContent(ExtendedEmailPublisher.java:659) at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:538) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:306) at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:297) at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:244) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734) at hudson.model.Build$BuildExecution.cleanUp(Build.java:192) at hudson.model.Run.execute(Run.java:1805) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) Caused by: java.io.FileNotFoundException: /var/lib/jenkins/workspace/Product1 (Is a directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream. (FileInputStream.java:146) at hudson.FilePath$33.invoke(FilePath.java:1749) at hudson.FilePath$33.invoke(FilePath.java:1742) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2677) at hudson.remoting.UserRequest.perform(UserRequest.java:121) at hudson.remoting.UserRequest.perform(UserRequest.java:49) at hudson.remoting.Request$2.run(Request.java:324) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)

Slide

unread,
Jan 14, 2015, 2:02:01 PM1/14/15
to jenkins...@googlegroups.com
Looks to me like its an issue in the template itself. Are you able to share it?

--
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/c3f481e3-ea9d-40e8-87a6-bb5b1a560a1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Don M

unread,
Jan 14, 2015, 3:19:43 PM1/14/15
to jenkins...@googlegroups.com
Yes I can share one of the templates.
It basically takes the example template that was shipped with older version of EmailExt plugin
And adds some code to look at the log for the job for Artifacts that were sent to Artifactory and adds links to the email.
The script is show below

I am able to run this as it is, in the email template testing.
I pulled out the custom code and it would still not run as it was originally named. (emailBody-HTML.template)
And al I had to do was change the name to groovy-html.template and it ran successfully.

Here is the template file
emailBody-HTML.template

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

<!-- ARTIFACTS IN ARTIFACTORY -->
<% def logFile = build.getRootDir().getPath() + "/log" 
   def outputFile = "var/lib/jenkins/email-templates/" + build.getId() 
   def command = "/var/lib/jenkins/email-templates/parseLogArtifactory.sh " + logFile + " " + outputFile
   def proc = command.execute()
   proc.waitFor()
   File outfile = new File( outputFile )
   if( outfile.exists() ) { %> 
<TABLE width="100%">
    <TR><TD class="bg1"><B>BUILD ARTIFACTS</B></TD></TR>
    <TR>
      <TD>
<%              outfile.eachLine() { line -> %>
            <a href="${print(line)}"></a>
<%              } %>
      </TD>
    </TR>
<%   } %>
 </TABLE>
<BR/>
<% outfile.delete() %>


<!-- 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/>
<% } %>


<!-- NOT USING ARTIFACTS, they are stored on ARTIFACTORY -->
<!-- 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/>  
<% } %>


<!-- MAVEN ARTIFACTS -->
<% 
try {
  def mbuilds = build.moduleBuilds
  if(mbuilds != null) { %>
  <TABLE width="100%">
      <TR><TD class="bg1"><B>BUILD ARTIFACTS</B></TD></TR>
<% 
    try {  
        mbuild.each() { m -> %>  
        <TR><TD class="bg2"><B>${m.key.displayName}</B></TD></TR>
<% m.value.each() { mvnbld ->
def artifactz = mvnbld.artifacts
if(artifactz != null && artifactz.size() > 0) { %>
      <TR>
        <TD>
<% artifactz.each() { f -> %>
         <li>
           <a href="${rooturl}${mvnbld.url}artifact/${f}">${f}</a>
         </li>
<% } %>
      </TD>
      </TR>
<%
}
       }
    } catch(e) {
// we don't do anything
    }  %>      
  </TABLE>
<BR/>
<% } 

}catch(e) {
// we don't do anything
}
%>

<!-- JUnit TEMPLATE -->

<% def junitResultList = it.JUnitTestResult
if (junitResultList.size() > 0) { %>
  <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>JUnit Tests</B></TD></TR>
    <% it.JUnitTestResult.each{ junitResult ->
      junitResult.getChildren().each { packageResult -> %>
        <TR><TD class="bg2" colspan="2"> Name: ${packageResult.getName()} Failed: ${packageResult.getFailCount()} test(s), Passed: ${packageResult.getPassCount()} test(s), Skipped: ${packageResult.getSkipCount()} test(s), Total: ${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()} test(s)</TD></TR>
        <% packageResult.getFailedTests().each{ failed_test -> %>
          <TR bgcolor="white"><TD class="test_failed" colspan="2"><B><li>Failed: ${failed_test.getFullName()} </li></B></TD></TR>
        <% }
      }
    }
} %>
  </TABLE>
<BR/>

<!-- CONSOLE OUTPUT -->
<% if(build.result==hudson.model.Result.FAILURE) { %>
<TABLE width="100%" cellpadding="0" cellspacing="0">
<TR><TD class="bg1"><B>CONSOLE OUTPUT</B></TD></TR>
<% build.getLog(100).each() { line -> %>
<TR><TD class="console">${org.apache.commons.lang.StringEscapeUtils.escapeHtml(line)}</TD></TR>
<% } %>
</TABLE>
<BR/>
<% } %>

</BODY>




From: Slide <slide...@gmail.com>
To: jenkins...@googlegroups.com
Sent: Wednesday, January 14, 2015 2:01 PM
Subject: Re: EmailExt 2.39

Slide

unread,
Jan 14, 2015, 3:20:43 PM1/14/15
to jenkins...@googlegroups.com
What does your ${SCRIPT} usage look like in the content area?

Don M

unread,
Jan 14, 2015, 3:30:19 PM1/14/15
to jenkins...@googlegroups.com
currently it is
${SCRIPT, template="groovy-html.template"}

It was
${SCRIPT, template="emailBody-HTML.template"}


From: Slide <slide...@gmail.com>
To: "jenkins...@googlegroups.com" <jenkins...@googlegroups.com>
Sent: Wednesday, January 14, 2015 3:20 PM
Subject: Re: EmailExt 2.39

Slide

unread,
Jan 14, 2015, 3:47:50 PM1/14/15
to jenkins...@googlegroups.com
I'm not having any issues locally with templates that are not named the "default" names with the same version, so let me look at your template again and see if I see anything.

Reply all
Reply to author
Forward
0 new messages