使用email-ext插件从Jenkins发送Cppcheck结果/报告 [英] Sending Cppcheck result/report on email from Jenkins using email-ext plugin

查看:440
本文介绍了使用email-ext插件从Jenkins发送Cppcheck结果/报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用Jenkins版本中的email-ext插件通过电子邮件发送 cppcheck 报告。到目前为止,唯一的方法似乎是通过创建自定义模板-果冻或普通纸。从这篇文章- 我可以配置jenkins发送带有静态分析报告摘要的电子邮件吗?-看起来我应该能够实例化CppcheckBuildAction并使用其方法,但是由于某些原因,它似乎无法实例化(即,该对象为null)。这是我放在果冻模板中进行检查的代码:

I'm trying to send cppcheck report on an email using email-ext plugin from a Jenkins build. So far, only way seems to be by creating a custom template -- jelly or groovy. From this post -- "Can I configure jenkins to send an email with a static analysis report summary?" -- it looks like I should be able to instantiate CppcheckBuildAction and use its methods but for some reason, it doesn't seem to instantiate (ie. the object is null). Here's the code I've put in the jelly template to check this:

<j:set var="cppcBuildAction" value="${it.getAction('com.thalesgroup.hudson.plugins.cppcheck.CppcheckBuildAction')}"/>
<j:if test="${cppcBuildAction==null}">
<p><i>cppcBuildAction is null!</i></p>
</j:if>

(我也尝试过hudson.plugins.cppcheck.CppcheckBuildAction)
而且,当然,在生成结果电子邮件中,我得到 cpppcBuildAction为空!。 (我必须在果冻中放入 if子句进行测试,因为它不会抛出任何错误,否则。在groovy模板中,我实际上收到了诸如 Exception:javax.script.ScriptException:java.lang .NullPointerException:如果尝试在对象上调用getResult方法,则无法在空对象上获取属性 getResult。

(I also tried hudson.plugins.cppcheck.CppcheckBuildAction) And, sure enough, I get cpppcBuildAction is null! in the build result email. (I had to put in "if" clause to test this on jelly because it doesn't throw out any error, otherwise. In groovy template, I actually get the error message like "Exception: javax.script.ScriptException: java.lang.NullPointerException: Cannot get property 'getResult' on null object" if I try to call getResult method on the object).

有人尝试过通过电子邮件发送Cppcheck结果/报告吗?使用此电子邮件扩展插件还是其他方式?

Has anybody tried sending Cppcheck result/report over email using this email-ext plugin or otherwise?

BTW,还有另一篇文章,其他人试图做我想做的事情,但线程不做似乎很活跃或没有进行任何真正的交互- 在哈德森的email-ext插件中使用cppcheck的果冻脚本模板有什么问题

BTW, there is another post where someone else is trying to do what I'm trying to do but the thread doesn't seem to be active or there's no real interaction going on there -- "What's wrong with following jelly script template for cppcheck in email-ext plugin of hudson"

推荐答案

您只是使用了错误的名称空间,正确的是:org.jenkinsci.plugins.cppche ck.CppcheckBuildAction。

You just use wrong namespace, right one is: org.jenkinsci.plugins.cppcheck.CppcheckBuildAction.

要调试,您可以使用以下代码:

For debugging you could use the following code:

<j:forEach var="a" items="${build.getActions()}">
action: ${a.getClass().getName()}
<BR/>
</j:forEach>

最后,以下代码对我有用:

And finally the following code works for me:

<!-- CppCheck TEMPLATE -->

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

享受!

这篇关于使用email-ext插件从Jenkins发送Cppcheck结果/报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆