Jenkins Email-ext插件构建日志全部在线

The*_*eth 2 email format plugins jelly jenkins

我在不同的地方都看到过这样的询问,但没有找到真正的答案。

有谁知道如何使用html.jelly模板使显示在正文中的构建日志不是全部一起运行,并使用换行符实际分隔每行?

我很确定答案在于模板需要进行某种更改,但是我不知道从哪里开始。

现在,我在电子邮件中收到此信息:

    [copy] Copying 1 file to /opt/hybris/hybris/bin/ext-channel/cscockpit/resources/localization [mkdir] Created dir: /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc [echo] [jspcompile] generating.. [echo] [jspcompile] touching jsp files [echo] [jspcompile] compiling.. /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc [yjavac] Compiling 209 source files to /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc [touch] Creating /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc/jspcompile_touch [stopwatch] [build: 36.436 sec] server: [echo] [echo] Configuring server at /opt/hybris/hybris/bin/platform/tomcat-6 [echo] Using config set at /opt/hybris/hybris/config/tomcat [echo] [copy] Copying 8 files to /opt/hybris/hybris/bin/platform/tomcat-6 [copy] Copying 6 files to /opt/hybris/hybris/bin/platform/tomcat-6 [copy] Copying 1 file to /opt/hybris/hybris/bin/platform/tomcat-6/lib [java] Process not found [java] shutting down hybris registry.. all: [echo] Build finished on 24-March-2014 07:09:01. [echo] BUILD SUCCESSFUL Total time: 42 seconds SSH: EXEC: completed after 59,838 ms SSH: Disconnecting configuration [Dev-trunk] ... SSH: Transferred 3 file(s) Email was triggered for: Success Sending email for trigger: Success 
Run Code Online (Sandbox Code Playgroud)

但我希望它看起来像这样...

[copy] Copying 1 file to /opt/hybris/hybris/bin/ext-channel/cscockpit/resources/localization 
[mkdir] Created dir: /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc 
echo] 
jspcompile] generating.. 
[echo] 
[jspcompile] touching jsp files 
[echo] 
[jspcompile] compiling.. /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc [yjavac] Compiling 209 source files to /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc [touch] Creating /opt/hybris/hybris/bin/platform/tomcat-6/work/Catalina/localhost/hmc/jspcompile_touch 
[stopwatch] 
[build: 36.436 sec] server: 
[echo] 
[echo] Configuring server at /opt/hybris/hybris/bin/platform/tomcat-6 
[echo] Using config set at /opt/hybris/hybris/config/tomcat 
[echo] 
[copy] Copying 8 files to /opt/hybris/hybris/bin/platform/tomcat-6 
[copy] Copying 6 files to /opt/hybris/hybris/bin/platform/tomcat-6 
[copy] Copying 1 file to /opt/hybris/hybris/bin/platform/tomcat-6/lib 
[java] Process not found 
[java] shutting down hybris registry.. all: 
[echo] Build finished on 24-March-2014 07:09:01. 
[echo] BUILD SUCCESSFUL Total time: 42 seconds SSH: EXEC: completed after 59,838 ms SSH: Disconnecting configuration 
[Dev-trunk] ... SSH: Transferred 3 file(s) Email was triggered for: Success Sending email for trigger: Success 
Run Code Online (Sandbox Code Playgroud)

low*_*tty 5

抱歉让您久等了。今天,我可以访问我的jenkins服务器,并尝试了Jelly模板,它可以正常工作。

首先,ext-mail插件的WIKI非常有用,这是链接:ext-mail wiki

我的jenkins的安装路径与您的相同:/ var / lib / jenkins /,但是我没有找到JELLY模板文件html.jelly,我使​​用了WIKI中的文件,并且这里是链接:html.jelly

现在,我将展示我的工作以及获得的结果:

  • 实际上,我将模板文件html.jelly放在/ var / lib / jenkins / email-templates中,请注意,根据WIKI,您需要在jenkins已安装文件夹下创建文件夹email-templates,以便扩展邮件插件中可以访问模板文件。我没有尝试过您指定的路径,所以我不知道如果将html.jelly放在以下目录下是否仍然可以工作:/ var / lib / jenkins / plugins / email-ext / WEB-INF / lib / hudson / plugins / emailext / templates。

  • 将html.jelly重命名为html_my.jelly。

  • 修改html_my.jelly,注释以下3行,以便控制台日志始终显示。
<!- 
<j:getStatic var =“ resultFailure” field =“ FAILURE” className =“ hudson.model.Result” /> />
<j:if test =“ $ {build.result == resultFailure}”> 
->
<TABLE width =“ 100%” cellpadding =“ 0” cellspacing =“ 0”>
<TR> <TD class =“ bg1”> <B>控制台输出</ B> </ TD> </ TR>
<j:forEach var =“ line” items =“ $ {build.getLog(100)}”> <TR> <TD class =“ console”> $ {line} </ TD> </ TR> </ j: forEach>
</ TABLE>
<BR/>
<!-</ j:if>->
  • Jenkins-管理Jenkins-配置系统-扩展电子邮件通知。将“默认内容类型”设置为“ HTML(text / html)”,然后将默认内容设置为${JELLY_SCRIPT, template="html_my"},我认为我们可以在Job的配置中设置默认内容也可以。请在此处参考图片: Jenkins系统配置

  • 在作业的配置中,还需要将内容类型修改为“ HTML(text / html)”,并且需要指定触发器类型。请参考配置作业的图像:配置工作

如您所见,下图是我的临时工作的电子邮件内容,希望对您有所帮助,如果您还有其他问题,请告诉我。 电子邮件内容示例

顺便说一句,使用groovy模板也很棒,您可以尝试!