简体   繁体   English

jenkins插件基于控制台输出构建失败

[英]jenkins plugin to fail build based on console output

Is there a plugin to fail a build if a pattern occurs on the console output? 如果控制台输出上出现模式,是否有一个插件可以使构建失败?

For example: 例如:

Build Action - success
Build Action - success
Build Action - error_pattern
Build Action - success

Let's assume that the Jenkins build process does not fail the build on error_pattern, I need to have an external fail trigger of some sort. 让我们假设Jenkins构建过程不会使构建在error_pattern上失败,我需要有某种外部失败触发器。

EDIT 编辑

Looking for a solution to fail the build during, not a post build task. 寻找一种解决方案,使构建失败,而不是构建后的任务。

You should try the Post Build Task plugin. 你应该尝试Post Build Task插件。 You can search for a pattern and then launch a script. 您可以搜索模式,然后启动脚本。

edit: There is also Text finder plugin , looks better for your problem 编辑:还有Text Finder插件 ,看起来更适合您的问题

As an ugly workaround I do the following: in the build script redirect all the output to some resulting .log file, then you can grep through this file in the background the way you like (personally I do the freezing check additionally - calculate the checksum and compare with previous, if the same - start counting for timeout until threshold), etc... 作为一个丑陋的解决方法,我执行以下操作:在构建脚本中将所有输出重定向到某个生成的.log文件,然后您可以在后台以您喜欢的方式浏览此文件(我个人另外进行冻结检查 - 计算校验和并与以前相比,如果相同 - 开始计算超时直到阈值)等...

Disadvantage is the output goes to some file instead of Jenkins console, but I guess you can do both using tee (I don't care, because my goal is to archive the log anyways and send it via email, - so I just gzip my resulting .log file and attach it as an artifact to the build record + to the email). 缺点是输出转到某些文件而不是Jenkins控制台,但我猜你可以使用tee做两件事(我不在乎,因为我的目标是将日志存档并通过电子邮件发送,所以我只是gzip我生成.log文件并将其作为工件附加到构建记录+到电子邮件)。

Advantage is you have full control on what happens in the build output and can interrupt the build using your own return code / message. 优点是您可以完全控制构建输出中发生的事情,并可以使用您自己的返回代码/消息中断构建。

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

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