我已经在不同的地方看到过这种问题但是没有找到真正的答案。
有没有人知道如何使用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
但我希望它看起来像这样......
[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
答案 0 :(得分:4)
首先,ext-mail插件的WIKI非常有用,这里是链接:ext-mail wiki
我的詹金斯'安装路径与你的相同:/ var / lib / jenkins /,但我没有找到JELLY模板文件html.jelly,我使用的是WIKI中的文件,这里是链接:html.jelly
现在我将展示我所做的和我得到的结果:
实际上我把模板文件html.jelly放在/ var / lib / jenkins / email-templates中,请注意根据WIKI,你需要在你的jenkins安装文件夹下创建文件夹email-templates,这样才能ext-mail插件可以访问模板文件。我没有尝试过您指定的路径,因此如果我将html.jelly放在目录下,我不知道它是否仍然有用:/ var / lib / jenkins / plugins / email-ext / WEB-INF / lib目录/哈德森/插件/ emailext /模板。
将html.jelly重命名为html_my.jelly。
<!-- <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>CONSOLE OUTPUT</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 - 配置系统 - 扩展电子邮件通知。
设置&#34;默认内容类型&#34;是&#34; HTML(text / html)&#34;,我在这里将默认内容设置为${JELLY_SCRIPT, template="html_my"}
,我认为我们可以在Job的配置中设置默认内容也可以。请参考此处的图片:
在您的工作配置中,您还需要将内容类型修改为&#34; HTML(text / html)&#34;,并且您需要指定触发器类型。请参阅配置作业的图像:
如您所见,下面的图片是我临时工作的电子邮件内容,希望这对您有所帮助,如果您有更多问题,请告诉我。
顺便说一句,使用groovy模板也很棒,你可以试试!