简体   繁体   English

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

[英]Jenkins Email-ext plugin build log all on one line

Ive seen this sort of asked in various places but haven't found a true answer. 我在不同的地方都看到过这样的询问,但没有找到真正的答案。

Does anyone know how to make the build log thats displayed in the body using the html.jelly template NOT all run together and to actually separate each line with a line break? 有谁知道如何使用html.jelly模板使构建日志在正文中显示出来,而不是同时运行并使用换行符实际分隔每行?

Im pretty sure the answer lies with some sort of change that needs to happen with the template but I have no idea where to begin. 我很确定答案在于模板需要进行某种更改,但是我不知道从哪里开始。

Right now I get this in my email: 现在,我在电子邮件中收到此信息:

    [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 

But I want it to look like this... 但我希望它看起来像这样...

[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 

Sorry to keep you waiting so long. 抱歉让您久等了。 Today I can access my jenkins server and I tried the Jelly template and it works fine. 今天,我可以访问我的jenkins服务器,并尝试了Jelly模板,它可以正常工作。

First of all, the WIKI of the ext-mail plug-in is very useful, here is the link: ext-mail wiki 首先,ext-mail插件的WIKI非常有用,这里是链接: ext-mail wiki

My jenkins' install path is the same as yours: /var/lib/jenkins/, but I have not find the JELLY Template file html.jelly, I use the file from the WIKI, and here is the link: html.jelly 我的jenkins的安装路径与您的相同:/ var / lib / jenkins /,但是我没有找到JELLY模板文件html.jelly,我使​​用了WIKI中的文件,并且这里是链接: html.jelly

Now I will show what I have done and the result I got: 现在,我将展示我的工作以及获得的结果:

  • Actually I put the template file html.jelly in /var/lib/jenkins/email-templates, note that according to the WIKI, you need to create the folder email-templates under your jenkins installed folder so that the ext-mail plug-in can access the template file. 实际上,我将模板文件html.jelly放在/ var / lib / jenkins / email-templates中,请注意,根据WIKI,您需要在jenkins已安装文件夹下创建文件夹email-templates,以便扩展邮件插件中可以访问模板文件。 I have no tried the path that you specified, so I don't know if it will still work if I put the html.jelly under the directory: /var/lib/jenkins/plugins/email-ext/WEB-INF/lib/hudson/plugins/emailext/templates. 我没有尝试过您指定的路径,因此,如果将html.jelly放在以下目录下,则不知道它是否仍然有效:/ var / lib / jenkins / plugins / email-ext / WEB-INF / lib /哈德森/插件/ emailext /模板。

  • Rename the html.jelly to html_my.jelly. 将html.jelly重命名为html_my.jelly。

  • Modify the html_my.jelly, comment the below 3 lines so that the console log will always show up. 修改html_my.jelly,注释以下3行,以便控制台日志始终显示。
<!-- 
&ltj:getStatic var="resultFailure" field="FAILURE" className="hudson.model.Result"/>
&ltj:if test="${build.result==resultFailure}"> 
-->
&ltTABLE width="100%" cellpadding="0" cellspacing="0">
&ltTR>&ltTD class="bg1">&ltB&gtCONSOLE OUTPUT</B></TD></TR>
&ltj:forEach var="line" items="${build.getLog(100)}">&ltTR>&ltTD class="console">${line}</TD></TR></j:forEach>
</TABLE>
&ltBR/>
<!-- </j:if> -->
  • Jenkins -- Manage Jenkins -- Configure System -- Extended E-mail Notification. Jenkins-管理Jenkins-配置系统-扩展电子邮件通知。 Set the "Default Content Type" to be "HTML (text/html)", and I set the default content here to ${JELLY_SCRIPT, template="html_my"} , and I think we can set Default Content in the Job's configuration will also work. 将“默认内容类型”设置为“ HTML(text / html)”,然后在此处将默认内容设置为${JELLY_SCRIPT, template="html_my"} ,我认为我们可以在Job的配置中设置默认内容也可以。 Refer the image here: 请在此处参考图片: Jenkins系统配置

  • In your job's configuration, you also need to modify the content type to be "HTML (text/html)", and you need to specify the trigger type. 在作业的配置中,还需要将内容类型修改为“ HTML(text / html)”,并且需要指定触发器类型。 Refer to the image of configure the Job: 请参考配置作业的图像: 配置工作

As you can see, the below image is the email content of my temp Job, hope that this will help you and if you have more question, please just let me know. 如您所见,下图是我的临时工作的电子邮件内容,希望对您有所帮助,如果您还有其他问题,请告诉我。 电子邮件内容示例

By the way, it's also wonderful to use the groovy template, you can try! 顺便说一句,使用groovy模板也很棒,您可以尝试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM