目前我在 Jenkins 可编辑的电子邮件信息中使用 BUILD_LOG_REGEX 来通过电子邮件记录错误。但我得到了很多垃圾,我想过滤掉错误,我希望将错误日志过滤到完美。有什么帮助吗?
答案 0 :(得分:13)
您的问题非常具体。正如Juuso Ohtonen在评论中指出的那样,你所做的很大程度上取决于你的日志中通常会发现什么。这是我们在其中一个工作中使用的一个例子,它是相当通用的(如果不是简约的话):
${BUILD_LOG_REGEX, regex="^.*?BUILD FAILED.*?$", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
我建议如下:创建一个记录一些包含您遇到的错误类型的文本的作业(您可能只是将一些文本文件放在作业的工作区中),然后使用Java正则表达式模式 - java.util.regex.Pattern - 在插件中,直到获得所需的结果。确保您只将作业中的电子邮件发送给自己:)
使用自定义HTML - 这是来自插件的内容令牌参考的引用:
${JELLY_SCRIPT, template} - Custom message content generated from a Jelly script
template. There are two templates provided: "html" and "text". Custom Jelly templates
should be placed in $JENKINS_HOME/email-templates. When using custom templates, the
template filename without ".jelly" should be used for the "template" argument.
template - the template name. Defaults to "html".
可用作起点的默认模板位于
中$JENKINS_HOME/plugins/email-ext/WEB-INF/classes/hudson/plugins/emailext/templates/html.jelly