Can I configure jenkins to send an email with a st

2019-03-17 00:22发布

I'd like to send an email after a build completes with some data from the reports that are run (PMD, Checkstyle, Findbugs, Cobertura) such as number of issues, new issues, coverage etc.

Is this possible?

3条回答
Ridiculous、
2楼-- · 2019-03-17 01:09

I've managed to get some data using the email-ext plugin. You need to include a jelly file in the email sent like this:

${JELLY_SCRIPT, template="html"}

There is a default template (html.jelly) which includes junit and Cobertura results which I've modified by adding something like this:

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
 ...
 <j:set var="fb" value="${it.getAction('hudson.plugins.findbugs.FindBugsResultAction')}" />
  <table width="100%">
   <tr><td colspan="2"><b>Findbugs Result</b></td></tr>
   <tr><td>Total:</td><td>${fb.result.numberOfWarnings}</td></tr>
   <tr><td>Fixed:</td><td>${fb.result.numberOfFixedWarnings}</td></tr>
   <tr><td>New:</td><td>${fb.result.numberOfNewWarnings}</td></tr>
   <tr><td colspan="2"><a href="${rooturl}${build.url}/findbugs">View Report</a></td></tr>
</table>
 ...
</j:jelly>

For PMD and CheckStyle you can do something similar with:

<j:set var="pmd" value="${it.getAction('hudson.plugins.pmd.PmdResultAction')}" />
<j:set var="cs" value="${it.getAction('hudson.plugins.checkstyle.CheckStyleResultAction')}" />

I've not yet found a way to include the low/medium/high priority figures for the results.

查看更多
倾城 Initia
3楼-- · 2019-03-17 01:11
<j:set var="pmd" value="${it.getAction('hudson.plugins.pmd.PmdResultAction')}" />
<j:if test="${pmd.isEmpty()!=true}">
   <TABLE width="100%">
       <TR><TD colspan="2" class="bg1"><B>PMD Result</B></TD></TR>
      <tr><td>Total:</td><td>${pmd.result.numberOfWarnings}</td></tr>
      <tr><td>High:</td><td>${pmd.result.getNumberOfAnnotations('HIGH')}</td></tr>
      <tr><td>Normal:</td><td>${pmd.result.getNumberOfAnnotations('NORMAL')}</td></tr>
      <tr><td>Low:</td><td>${pmd.result.getNumberOfAnnotations('LOW')}</td></tr>
      <tr><td>New:</td><td>${pmd.result.numberOfNewWarnings}</td></tr>
      <tr><td>Fixed:</td><td>${pmd.result.numberOfFixedWarnings}</td></tr>
      <tr><td colspan="2"><a href="${rooturl}${build.url}/pmdResult/">View Report</a></td></tr>
   </TABLE >    
<BR/>
</j:if>

Have a try! More check my gist here: https://gist.github.com/yangboz/9204868

查看更多
别忘想泡老子
4楼-- · 2019-03-17 01:20

In my case worked https://stackoverflow.com/a/22008267/1688570

For exact Action names look in \Jenkins\jobs\fispp-all-master\builds\${buildNumber}\build.xml file. I.e. I had to use hudson.plugins.findbugs.FindBugsMavenResultAction to show correct results.

查看更多
登录 后发表回答