我可以配置 jenkins 发送包含静态分析报告摘要的电子邮件吗?

发布于 2024-12-16 12:29:46 字数 105 浏览 4 评论 0原文

我想在构建完成后发送一封电子邮件,其中包含运行报告(PMD、Checkstyle、Findbugs、Cobertura)中的一些数据,例如问题数量、新问题、覆盖范围等。

这可能吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野侃 2024-12-23 12:29:46
<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>

尝试一下!更多内容请查看我的要点:https://gist.github.com/yangboz/9204868

<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

鲜肉鲜肉永远不皱 2024-12-23 12:29:46

我已经设法使用 email-ext 插件获取一些数据。您需要在发送的电子邮件中包含一个 jelly 文件,如下所示:

${JELLY_SCRIPT, template="html"}

有一个默认模板 (html.jelly),其中包括 junit 和 Cobertura 结果,我通过添加如下内容对其进行了修改:

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

对于 PMD和 CheckStyle 您可以执行类似的操作:

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

我还没有找到一种方法来包含结果的低/中/高优先级数字。

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.

始于初秋 2024-12-23 12:29:46

就我而言,工作 https://stackoverflow.com/a/22008267/1688570

对于确切的操作名称,请查看 \Jenkins\ jobs\fispp-all-master\builds\${buildNumber}\build.xml 文件。
即我必须使用 hudson.plugins.findbugs.FindBugsMavenResultAction 来显示正确的结果。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文