9

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

4

1 回答 1

19

您的问题相当不具体。正如 Juuso Ohtonen 在评论中指出的那样,您所做的很大程度上取决于您的日志中通常可以找到的内容。这是我们在一项工作中使用的示例,它相当通用(如果不是说简约的话):

${BUILD_LOG_REGEX, regex="^.*?BUILD FAILED.*?$", linesBefore=0, linesAfter=10, maxMatches=5, showTruncatedLines=false, escapeHtml=true}

我建议如下:创建一个记录一些包含您遇到的错误类型的文本的作业(您可能只是吐出一些放置在作业工作区中的文本文件),然后使用 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".

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

$JENKINS_HOME/plugins/email-ext/WEB-INF/classes/hudson/plugins/emailext/templates/html.jelly
于 2012-02-26T11:05:51.473 回答