Can I configure jenkins to send an email with a static analysis report summary?

匿名 (未验证) 提交于 2019-12-03 02:50:02

问题:

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?

回答1:

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.



回答2:

<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



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!