error when sending jelly template using email ext plugin with jenkins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

error when sending jelly template using email ext plugin with jenkins

jesus fernandez
I want to send the cppcheck report through email but I had never used the email ext plugin before, so I found this  https://stackoverflow.com/questions/13888338/sending-cppcheck-result-report-on-email-from-jenkins-using-email-ext-plugin with a nice jelly template to do so, I have also followed the steps in the documentation, to send my own templates in a pipeline job, I have created my template with a .jelly extension and set it into my ```$JENKINS_HOME\email-templates``` although the email-templates folder did not exist, so I am not sure if it should be created beforehand just by installing the plugin or what I am missing. This is my stage
```
        stage('Mail cppcheck report') {
            steps{
                script{
                    def mailRecipients = "[hidden email]"
                    def jobName = currentBuild.fullDisplayName
                    mimeType: 'text/html'
                    emailext body: '''${JELLY_SCRIPT, template="custom"}''',
                    subject: "[Jenkins] ${jobName}",
                    to: "${mailRecipients}" 
                }
            }
        }
```

And this is the template I want to use but I keep getting the following error ``` JellyException: Could not parse Jelly script : null``` even though the email is sent the email body is just the error mentioned above.

```
<j:set var="cppcheckAction" value="${it.getAction('org.jenkinsci.plugins.cppcheck.CppcheckBuildAction')}" />
<j:if test="${cppcheckAction!=null}">
    <j:set var="cppcheckResult" value="${cppcheckAction.getResult()}" />
    <j:if test="${cppcheckResult!=null}">
        <TABLE width="100%">
            <TR><TD class="bg1" colspan="2"><B>CPPCHECK RESULT</B></TD></TR>
            <TR bgcolor="white"><TD class="test_failed" colspan="2"><B><li><a href="${rooturl}${build.url}cppcheckResult">Found: ${cppcheckResult.report.getNumberTotal()}</a></li></B></TD></TR>
        </TABLE>
        <BR/>
    </j:if>
</j:if>
```
I have also tried with some other templates and I get no error but I receive an empty email instead, like with this one. 
```
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
  <html>
    <j:set var="cppcheckAction" value="${it.getAction('org.jenkinsci.plugins.cppcheck.CppcheckBuildAction')}" />
      <j:if test="${cppcheckAction!=null}">
    <j:set var="cppcheckResult" value="${cppcheckAction.getResult()}" />
    <j:if test="${cppcheckResult!=null}">
      <h2>Summary</h2>
        <style type="text/css">
    #cppcheckStatistics { width: auto; }
    #cppcheckStatistics .number { text-align: right; }
        </style>
        <table class="pane sortable" id="cppcheckStatistics">
          <thead>
            <tr>
              <td class="pane-header">Severity</td>
              <td class="pane-header">Count</td>
              <td class="pane-header">Delta</td>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td class="pane">Error</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberErrorSeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberErrorSeverity()}</td>
            </tr>
            <tr>
              <td class="pane">Warning</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberWarningSeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberWarningSeverity()}</td>
            </tr>
            <tr>
              <td class="pane">Style</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberStyleSeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberStyleSeverity()}</td>
            </tr>
            <tr>
              <td class="pane">Performance</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberPerformanceSeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberPerformanceSeverity()}</td>
            </tr>
            <tr>
              <td class="pane">Portability</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberPortabilitySeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberPortabilitySeverity()}</td>
            </tr>
            <tr>
              <td class="pane">Information</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberInformationSeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberInformationSeverity()}</td>
            </tr>
            <tr>
              <td class="pane">No category</td>
              <td class="pane number">${cppcheckResult.statistics.getNumberNoCategorySeverity()}</td>
              <td class="pane number">${cppcheckResult.getDiff().getNumberNoCategorySeverity()}</td>
            </tr>
          </tbody>
          <tfoot>
            <tr class="sortbottom">
              <td class="pane-header">Total</td>
              <td class="pane-header number"><B><a href="${rooturl}${build.url}cppcheckResult">${cppcheckResult.report.getNumberTotal()}</a></B></td>
              <td class="pane-header number"><B><a href="${rooturl}${build.url}cppcheckResult/source.all/?before=5&amp;after=5&amp;states=new">${cppcheckResult.getDiff().getNumberTotal()}</a></B></td>
            </tr>
          </tfoot>
        </table>
      </j:if>
    </j:if>
  </html>
</j:jelly>
```

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8ea4ff9c-1e1f-4b63-b05c-7b04bad9f310n%40googlegroups.com.