电子邮件扩展插件-无法使BUILD_LOG_EXCERPT正常工作 [英] Email Extension Plugin - can't get BUILD_LOG_EXCERPT to work

查看:114
本文介绍了电子邮件扩展插件-无法使BUILD_LOG_EXCERPT正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我在BUILD_LOG_EXCERPT中输入什么内容,我所收到的都是一封空正文的电子邮件,因此可以使用一些帮助.

No matter what I put in BUILD_LOG_EXCERPT, all I get is an email with an empty body, thus could use some assistance.

我有一个写入控制台的Java程序. Jenkins控制台输出的片段如下所示:

I have a java program that writes to console. Snippet of Jenkins console output looks like this:

...
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building project1 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ project1 ---
Parameters provided: SG, 100, 1000
query: select COUNT(*) from table1 where col1 = ? and col2 = ? and col3 = ?
Rows in table: 5776
Threshold: 100
Rows returned above threshold, skipping dpan generation batch file.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.125 s
[INFO] Finished at: 2016-02-08T09:31:37-08:00
[INFO] Final Memory: 8M/245M
...

在Jenkins作业中,我创建一个Post Build步骤,并将以下行放入Default Content:

In the Jenkins job, I create a Post Build step, and put the following line in Default Content:

${BUILD_LOG_EXCERPT, start="\\b(Parameters)\\b", end="\\b(Threshold)\\b"}

当我触发工作时,我收到的只是一封空电子邮件.但是,如果我添加

When I trigger the job, all i get is an empty email. However if I add

${BUILD_LOG, maxLines=9999, escapeHtml=false}

然后我会在电子邮件中获得完整的控制台输出.有任何想法吗?我正在使用插件的2.40.3版本.

then i get the full console output in the email. Any ideas? I am using version 2.40.3 of the plugin.

推荐答案

好像您的正则表达式找不到任何匹配项,因此您不会得到日志的任何行.这是因为BUILD_LOG_EXCERPT变量使用java.util.regex.Pattern.Matcher.matches()来匹配正则表达式-如果 entire 字符串匹配(仅在

Looks like your regex is failing to find any matches, so you aren't getting any lines of the log. This is because the BUILD_LOG_EXCERPT variable uses java.util.regex.Pattern.Matcher.matches() to match a regex - and this will only return True if the entire string matches (referenced in this SO question). The log parser is running line-by-line, so it's testing your entire line against your regex and failing (since there are characters after "Parameters").

如果您要查找以Parameters开头但后面可能包含字符的字符串,则可以匹配

If you're looking for a string that starts with Parameters but may have characters after it, you can match to

"\\b(Parameters)\\b(?s).*"

将匹配参数"及其后的任意字符串.

which will match "Parameters" and any arbitrary string after it.

这篇关于电子邮件扩展插件-无法使BUILD_LOG_EXCERPT正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆