Hi,

I have been using email-ext plugin bundled script "html.jelly" for email. 
But now i want to add changes since last success in email.

I have tried some code provided here 
"http://stackoverflow.com/questions/6386635/infinite-loop-in-jelly-script-for-jenkins-email-ext-plugin-why";,
 
but getting "JellyException: null:82:63: **Java heap space" error

Jenkins log:

Jan 23, 2013 12:58:13 AM 
hudson.plugins.emailext.plugins.content.JellyScriptContent getContent
SEVERE: null
org.apache.commons.jelly.JellyTagException: null:82:63: <j:forEach> Java heap 
space
        at 
org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:745)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:289)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
        at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
        at 
org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:124)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at 
org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
        at org.apache.commons.jelly.tags.core.WhileTag.doTag(WhileTag.java:62)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
        at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
        at 
org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:124)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at 
org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
        at 
hudson.plugins.emailext.plugins.content.JellyScriptContent.convert(JellyScriptContent.java:126)
        at 
hudson.plugins.emailext.plugins.content.JellyScriptContent.renderContent(JellyScriptContent.java:117)
        at 
hudson.plugins.emailext.plugins.content.JellyScriptContent.getContent(JellyScriptContent.java:73)
        at 
hudson.plugins.emailext.plugins.ContentBuilder.replaceTokensWithContent(ContentBuilder.java:123)
        at 
hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:96)
        at 
hudson.plugins.emailext.ExtendedEmailPublisher.getContent(ExtendedEmailPublisher.java:662)
        at 
hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:457)
        at 
hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:297)
        at 
hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:289)
        at 
hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:249)
        at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
        at 
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
        at 
hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:692)
        at hudson.model.Build$BuildExecution.cleanUp(Build.java:192)
        at hudson.model.Run.execute(Run.java:1546)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
        at hudson.model.ResourceController.execute(ResourceController.java:88)
        at hudson.model.Executor.run(Executor.java:236)
Caused by: java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at java.io.ByteArrayOutputStream.write(Unknown Source)
        at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
        at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
        at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
        at sun.nio.cs.StreamEncoder.flush(Unknown Source)
        at java.io.OutputStreamWriter.flush(Unknown Source)
        at java.io.BufferedWriter.flush(Unknown Source)
        at org.dom4j.io.XMLWriter.flush(XMLWriter.java:276)
        at org.apache.commons.jelly.XMLOutput.flush(XMLOutput.java:127)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:271)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
        at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
        at 
org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:124)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at 
org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
        at org.apache.commons.jelly.tags.core.WhileTag.doTag(WhileTag.java:62)
        at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161)
        at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
        at 
org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:124)
        at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
        at 
org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105)
        at 
hudson.plugins.emailext.plugins.content.JellyScriptContent.convert(JellyScriptContent.java:126)
        at 
hudson.plugins.emailext.plugins.content.JellyScriptContent.renderContent(JellyScriptContent.java:117)
        at 
hudson.plugins.emailext.plugins.content.JellyScriptContent.getContent(JellyScriptContent.java:73)
        at 
hudson.plugins.emailext.plugins.ContentBuilder.replaceTokensWithContent(ContentBuilder.java:123)
        at 
hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:96)

Jan 23, 2013 12:58:03 AM hudson.model.Run execute
INFO: test #54 main build action completed: FAILURE






Modified html.jelly script:


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

<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>
  <tr><td>Build cause:</td><td><j:forEach var="cause" items="${build.causes}"> 
<b>${cause.shortDescription}</b> </j:forEach></td></tr>
  <tr><td>Build description:</td><td>${build.description}</td></tr>
  <tr><td>Built on:</td><td><j:choose><j:when 
test="${build.builtOnStr!=''}">${build.builtOnStr}</j:when><j:otherwise>master</j:otherwise></j:choose></td></tr>
</TABLE>
<BR/>

    <!-- HEALTH TEMPLATE -->
    <div class="content">
      <j:set var="healthIconSize" value="16x16" />
      <j:set var="healthReports" value="${project.buildHealthReports}" />
      <j:if test="${healthReports!=null}">
        <h3>Health Report</h3>
        <table><tr><th>W</th><th>Description</th><th>Score %</th></tr>
          <j:forEach var="healthReport" items="${healthReports}">
            <tr><td><img 
src="${rooturl}${healthReport.getIconUrl(healthIconSize)}" /></td>
              
<td>${healthReport.description}</td><td>${healthReport.score}</td></tr>
          </j:forEach>
        </table>
        <br />
      </j:if>
    </div>


<!-- Added for changes since last success-->

<j:set var="changesBuild" value="${build.previousNotFailedBuild}" />
<j:if test="${changesBuild!=null}">
  <j:set var="changesBuild" value="${changesBuild.nextBuild}" />
</j:if>
<j:if test="${changesBuild==null}">
  <j:set var="changesBuild" value="build" scope="parent"  />
</j:if>

<j:while test="${changesBuild!=null}">
  <j:set var="changeSet" value="${changesBuild.changeSet}" />
  <j:if test="${changeSet!=null}">
  <j:set var="hadChanges" value="false" />
    <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR>
    <j:forEach var="cs" items="${changeSet}" varStatus="loop">
      <j:set var="hadChanges" value="true" />
      <j:set var="aUser" value="${cs.hudsonUser}"/>
      <TR>
        <TD colspan="2" class="bg2">${spc}Revision 
<B>${cs.commitId?:cs.revision?:cs.changeNumber}</B> by
          <B>${aUser!=null?aUser.displayName:cs.author.displayName}: </B> 
${cs.Date} ${cs.Workspace.name}
          <B>(${cs.msgAnnotated})</B>
         </TD>
      </TR>
      <j:forEach var="p" items="${cs.affectedFiles}">
        <TR>
          <TD width="10%">${spc}${p.editType.name}</TD>
         <TD>${p.path} ${p.revision}</TD>
        </TR>
      </j:forEach>
    </j:forEach>
    <j:if test="${!hadChanges}">
      <TR><TD colspan="2">No Changes</TD></TR>
    </j:if>
    </TABLE>
    <BR/>
  </j:if>
  <j:set var="changesBuild" value="changesBuild.nextBuild" scope="parent" />
</j:while>

        
        
        
        

<!-- CHANGE SET -->

<j:set var="changeSet" value="${build.changeSet}" />
<j:if test="${changeSet!=null}">
  <j:set var="hadChanges" value="false" />
  <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR>
    <j:forEach var="cs" items="${changeSet}" varStatus="loop">
      <j:set var="hadChanges" value="true" />
      <j:set var="aUser" value="${cs.hudsonUser}"/>
      <TR>
        <TD colspan="2" class="bg2">${spc}Revision 
<B>${cs.commitId?:cs.revision?:cs.changeNumber}</B> by
          <B>${aUser!=null?aUser.displayName:cs.author.displayName}: </B> 
${cs.Date} ${cs.Workspace.name}
          <B>(${cs.msgAnnotated})</B>
         </TD>
      </TR>
      <j:forEach var="p" items="${cs.affectedFiles}">
        <TR>
          <TD width="10%">${spc}${p.editType.name}</TD>
          <TD>${p.path} ${p.revision}</TD>
                 </TR>
      </j:forEach>
    </j:forEach>
    <j:if test="${!hadChanges}">
      <TR><TD colspan="2">No Changes</TD></TR>
    </j:if>
  </TABLE>
<BR/>
</j:if>


<!-- ARTIFACTS -->

<j:set var="artifacts" value="${build.artifacts}" />
<j:if test="${artifacts!=null and artifacts.size()&gt;0}">
  <TABLE width="100%">
    <TR><TD class="bg1"><B>BUILD ARTIFACTS</B></TD></TR>
    <TR>
      <TD>
        <j:forEach var="f" items="${artifacts}">
          <li>
            <a href="${rooturl}${build.url}artifact/${f}">${f}</a>
          </li>
        </j:forEach>
      </TD>
    </TR>
  </TABLE>
<BR/>  
</j:if>


<!-- MAVEN ARTIFACTS -->

<j:set var="mbuilds" value="${build.moduleBuilds}" />
<j:if test="${mbuilds!=null}">
  <TABLE width="100%">
      <TR><TD class="bg1"><B>BUILD ARTIFACTS</B></TD></TR>
      <j:forEach var="m" items="${mbuilds}">
        <TR><TD class="bg2"><B>${m.key.displayName}</B></TD></TR>
        <j:forEach var="mvnbld" items="${m.value}">
        <j:set var="artifacts" value="${mvnbld.artifacts}" />
        <j:if test="${artifacts!=null and artifacts.size()&gt;0}">
      <TR>
        <TD>
          <j:forEach var="f" items="${artifacts}">
            <li>
              <a href="${rooturl}${mvnbld.url}artifact/${f}">${f}</a>
            </li>
          </j:forEach>
        </TD>
      </TR>
        </j:if>
        </j:forEach>
      </j:forEach>
  </TABLE>
<BR/>  
</j:if>


<!-- JUnit TEMPLATE -->

<j:set var="junitResultList" value="${it.JUnitTestResult}" />
<j:if test="${junitResultList.isEmpty()!=true}">
  <TABLE width="100%">
    <TR><TD class="bg1" colspan="2"><B>JUnit Tests</B></TD></TR>
    <j:forEach var="junitResult" items="${it.JUnitTestResult}">
      <j:forEach var="packageResult" items="${junitResult.getChildren()}">
        <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>
        <j:forEach var="failed_test" items="${packageResult.getFailedTests()}">
          <TR bgcolor="white"><TD class="test_failed" 
colspan="2"><B><li>Failed: ${failed_test.getFullName()} </li></B></TD></TR>
        </j:forEach>
      </j:forEach> 
    </j:forEach>  
  </TABLE>      
<BR/>
</j:if>


<!-- COBERTURA TEMPLATE -->

<j:set var="coberturaAction" value="${it.coberturaAction}" />
<j:if test="${coberturaAction!=null}">
  <j:set var="coberturaResult" value="${coberturaAction.result}" />
  <j:if test="${coberturaResult!=null}">
        <table width="100%"><TD class="bg1" colspan="2"><B>Cobertura 
Report</B></TD></table>
        <table width="100%"><TD class="bg2" colspan="2"><B>Project Coverage 
Summary</B></TD></table>
            <table border="1px" class="pane">
                <tr>
                    <td>Name</td>
                    <j:forEach var="metric" items="${coberturaResult.metrics}">
                        <td>${metric.name}</td>
                    </j:forEach>
                </tr>
                <tr>
                    <td>${coberturaResult.name}</td>
                    <j:forEach var="metric" items="${coberturaResult.metrics}">
                        <td 
data="${coberturaResult.getCoverage(metric).percentageFloat}">${coberturaResult.getCoverage(metric).percentage}%
                            (${coberturaResult.getCoverage(metric)})
                        </td>
                    </j:forEach>
                </tr>
            </table>

            <j:if test="${coberturaResult.sourceCodeLevel}">
                <h2>Source</h2>
                <j:choose>
                    <j:when test="${coberturaResult.sourceFileAvailable}">
                        <div style="overflow-x:scroll;">
                            <table class="source">
                                <thead>
                                    <tr>
                                        <th 
colspan="3">${coberturaResult.relativeSourcePath}</th>
                                    </tr>
                                </thead>
                                ${coberturaResult.sourceFileContent}

                            </table>
                        </div>
                    </j:when>
                    <j:otherwise>
                        <p>
                            <i>Source code is unavailable</i>
                        </p>
                    </j:otherwise>
                </j:choose>
            </j:if>

            <j:forEach var="element" items="${coberturaResult.childElements}">
                <j:set var="childMetrics" 
value="${coberturaResult.getChildMetrics(element)}"/>
               <table width="100%"><TD class="bg2" colspan="2">Coverage 
Breakdown by ${element.displayName}</TD></table>
                <table border="1px" class="pane sortable">
                    <tr>
                        <td>Name</td>
                        <j:forEach var="metric" items="${childMetrics}">
                            <td>${metric.name}</td>
                        </j:forEach>
                    </tr>
                    <j:forEach var="c" items="${coberturaResult.children}">
                        <j:set var="child" 
value="${coberturaResult.getChild(c)}"/>
                        <tr>

                            <td>
                                ${child.xmlTransform(child.name)}
                            </td>
                            <j:forEach var="metric" items="${childMetrics}">
                                <j:set var="childResult" 
value="${child.getCoverage(metric)}"/>
                                <j:choose>
                                    <j:when test="${childResult!=null}">
                                        <td 
data="${childResult.percentageFloat}">${childResult.percentage}%
                                            (${childResult})
                                        </td>
                                    </j:when>
                                    <j:otherwise>
                                        <td data="101">N/A</td>
                                    </j:otherwise>
                                </j:choose>
                            </j:forEach>
                        </tr>
                    </j:forEach>
                </table>
            </j:forEach>
  </j:if>
<BR/>
</j:if>


<!-- CONSOLE OUTPUT -->

<j:getStatic var="resultFailure" field="FAILURE" 
className="hudson.model.Result"/>
<j:if test="${build.result==resultFailure}">
<TABLE width="100%" cellpadding="0" cellspacing="0">
<TR><TD class="bg1"><B>CONSOLE OUTPUT</B></TD></TR>
<j:forEach var="line" items="${build.getLog(50)}"><TR><TD 
class="console">${line}</TD></TR></j:forEach>
</TABLE>
<BR/>
</j:if>

</BODY>
</j:jelly>




Can any one please help me get this report. Thanks in advance.


Reply via email to