我如何仅过滤掉Jenkins-email-ext,BUILD_LOG_REGEX中的错误?

use*_*613 9 regex email-integration jenkins jenkins-plugins email-ext

目前我在Jenkins可编辑的电子邮件信息中使用BUILD_LOG_REGEX来通过电子邮件获取错误日志.但我得到了很多垃圾,我想过滤掉错误,我希望将错误日志过滤到完美.有帮助吗?

mal*_*cot 16

你的问题非常具体.正如Juuso Ohtonen在评论中指出的那样,你所做的很大程度上取决于你的日志中通常会发现什么.以下是我们在其中一个工作中使用的示例,它是相当通用的(如果不是简约的话):

${BUILD_LOG_REGEX, regex="^.*?BUILD FAILED.*?$", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}
Run Code Online (Sandbox Code Playgroud)

我建议如下:创建一个记录一些包含您遇到的错误类型的文本的作业(您可能只是将一些文本文件放在作业的工作区中),然后使用Java正则表达式模式 - java.util.regex.模式 - 在插件中直到获得所需的结果.确保您只将作业中的电子邮件发送给自己:)

要使用自定义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".
Run Code Online (Sandbox Code Playgroud)

您可以用作起点的默认模板位于

$JENKINS_HOME/plugins/email-ext/WEB-INF/classes/hudson/plugins/emailext/templates/html.jelly
Run Code Online (Sandbox Code Playgroud)