需要正则表达式在jenkins管道的email-ext插件中仅包含控制台输出中的特定行

时间:2019-04-24 07:32:07

标签: regex jenkins-pipeline jenkins-email-ext

需要包括jenkins管道控制台输出中的特定行(某些ID),并使用email-ext插件发送。我如何为此编写正则表达式。 例如:

Console ouput
published xyz
[servername] out: Built 123abcwxyabjd
few lines of o/p
[servername2] out: Built ewrewfdsfabcwxyabjd
again some o/p
[servername3] out: Built 1458543abcwxyabjd
published abc
some o/p
[servername2] out: Built dfds123abcwxyabjd
some o/p
[servername] out: Built dsfdsabcwxyabjd

我在o / p中需要什么

published xyz
[servername] out: Built 123abcwxyabjd
[servername2] out: Built ewrewfdsfabcwxyabjd
[servername3] out: Built 1458543abcwxyabjd
published abc
[servername2] out: Built dfds123abcwxyabjd
[servername] out: Built dsfdsabcwxyabjd

另一个问题是阶段是并行的,即 已发布的xyz和已发布的abc是并行的,并且将不按顺序输出ID

对我来说,我可以获得

之类的所有行
[servername] out: Built 123abcwxyabjd
[servername] out: Built 123abcwxyabjd



$(BUILD_LOG_REGEX, regex=".*(?=.*?Built).*?$

对我来说,我可以获得

之类的所有行
[servername] out: Built 123abcwxyabjd
[servername] out: Built 123abcwxyabjd

,但无法区分哪个是哪个发布阶段。 即使我可以先选择三个ID,然后再发布文本,然后再选择三个ID,然后再发布一些文本。可能会有所帮助。

1 个答案:

答案 0 :(得分:0)

尝试

^(.* out: Built|published ).*$

请参见https://regex101.com/r/CuAYph/2右侧也有解释