简体   繁体   English

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

[英]Need regex to included only specific lines from console output in email-ext plugin in jenkins pipeline

Need to include specific lines(some ID) from jenkins pipeline console output and send it using email-ext plugin. 需要包含来自jenkins管道控制台输出的特定行(某些ID)并使用email-ext插件发送它。 How I can write the regex for this. 我怎么能写这个正则表达式。 For Example: 例如:

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

What I need in o/p 在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

one more is issue is that stages are in parallel ie published xyz and published abc are in parallel and will output the ID's not in sequence 另一个问题是阶段是并行的,即发布的xyz和发布的abc是并行的,并且将不按顺序输出ID

For me I'm able to get all the lines like 对我来说,我能够得到所有的线条

[servername] out: Built 123abcwxyabjd
[servername] out: Built 123abcwxyabjd



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

For me I'm able to get all the lines like 对我来说,我能够得到所有的线条

[servername] out: Built 123abcwxyabjd
[servername] out: Built 123abcwxyabjd

but not able to differentiate which is from which published stage. 但无法区分哪个发布阶段。 Even if I can select first three id and then publish text and then three id and then some text. 即使我可以选择前三个id然后发布文本然后三个id然后一些文本。 May be it will be helpful. 可能会有所帮助。

Try 尝试

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

see https://regex101.com/r/CuAYph/2 There is also explanation on right 请参阅https://regex101.com/r/CuAYph/2右侧也有解释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM