使用jenkins的电子邮件ext插件发送果冻模板时出错
我想通过电子邮件发送cppcheck报告,但我以前从未使用过email ext插件,因此我找到了一个很好的jelly模板。为此,我还按照文档中的步骤,在管道作业中发送我自己的模板,我已经用.jelly扩展名创建了我的模板,并将其设置到我的使用jenkins的电子邮件ext插件发送果冻模板时出错,jenkins,groovy,jenkins-pipeline,jelly,Jenkins,Groovy,Jenkins Pipeline,Jelly,我想通过电子邮件发送cppcheck报告,但我以前从未使用过email ext插件,因此我找到了一个很好的jelly模板。为此,我还按照文档中的步骤,在管道作业中发送我自己的模板,我已经用.jelly扩展名创建了我的模板,并将其设置到我的$JENKINS\u HOME\email templates中,尽管email templates文件夹不存在,所以我不确定是否应该通过安装插件或我缺少的东西来预先创建模板。这是我的舞台 stage('Mail cppcheck report'
$JENKINS\u HOME\email templates
中,尽管email templates文件夹不存在,所以我不确定是否应该通过安装插件或我缺少的东西来预先创建模板。这是我的舞台
stage('Mail cppcheck report') {
steps{
script{
def mailRecipients = "email@email.net"
def jobName = currentBuild.fullDisplayName
mimeType: 'text/html'
emailext body: '''${JELLY_SCRIPT, template="custom"}''',
subject: "[Jenkins] ${jobName}",
to: "${mailRecipients}"
}
}
}
这是我想要使用的模板,但我一直收到以下错误Jelly异常:无法解析Jelly脚本:null
,即使发送了电子邮件,电子邮件正文也只是上面提到的错误
<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>
检查结果
我也尝试了一些其他模板,我没有收到任何错误,但我收到了一封空电子邮件,就像这封一样
<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&after=5&states=new">${cppcheckResult.getDiff().getNumberTotal()}</a></B></td>
</tr>
</tfoot>
</table>
</j:if>
</j:if>
</html>
</j:jelly>
总结
#cppcheckStatistics{width:auto;}
#cppcheckStatistics.number{text align:right;}
严重程度
计数
三角洲
错误
${cppcheckResult.statistics.getNumberErrorSeverity()}
${cppcheckResult.getDiff().getNumberErrorSeverity()}
警告
${cppcheckResult.statistics.getNumberWarningSeverity()}
${cppcheckResult.getDiff().getNumberWarningSeverity()}
风格
${cppcheckResult.statistics.getNumberStyleSeverity()}
${cppcheckResult.getDiff().getNumberStyleSeverity()}
演出
${cppcheckResult.statistics.getNumberPerformanceSeverity()}
${cppcheckResult.getDiff().getNumberPerformanceSeverity()}
便携性
${cppcheckResult.statistics.getNumberPortabilitySeverity()}
${cppcheckResult.getDiff().getNumberPortabilitySeverity()}
问询处
${cppcheckResult.statistics.getNumberInformationSeverity()}
${cppcheckResult.getDiff().getNumberInformationSeverity()}
无类别
${cppcheckResult.statistics.GetNumberLocategorySeverity()}
${cppcheckResult.getDiff().GetNumberLocategorySeverity()}
全部的
但是,如果我使用默认模板emailext正文:'${JELLY\u SCRIPT,template=“html”}'
它可以正常工作