目前,我在中使用 BUILD_LOG_REGEX Jenkins 可编辑电子邮件信息,以通过电子邮件获取错误日志。但是我遇到了很多垃圾,我想过滤掉错误,并且希望将错误日志过滤到完美。有什么帮助吗?
最佳答案
您的问题不是很具体。正如Juuso Ohtonen在评论中指出的那样,您所做的工作高度依赖于通常可以在日志中找到的内容。这是我们在一项工作中使用的示例,它是通用的(如果不是要说简约的话):
${BUILD_LOG_REGEX, regex="^.*?BUILD FAILED.*?$", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
我建议采取以下措施:创建一个作业,记录一些文本,其中包含您遇到的错误类型(您可能会吐出一些放置在作业工作区中的文本文件),然后在插件中使用Java regex模式-java.util.regex.Pattern-直到您会得到理想的结果。确保仅将作业中的电子邮件发送给自己:)
要使用自定义HTML-这是“插件的内容 token ”引用中的引号:
${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
关于regex - 我如何仅过滤掉Jenkins-email-ext,BUILD_LOG_REGEX中的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9439450/