避免使用大型日志 Jenkins 文件(并在需要时停止构建)

Avoid large log Jenkins file (and stop build if needed)

我们正在使用 Jenkins(在 Linux 上)来管理我们的 Maven 构建。

我们的用户可以创建自己的作业,有时(每年 3 或 4 次),他们犯了错误,作业会生成一个很大的日志文件(上次是 79 GB...)。

我查看了现有的插件,但没有找到可以监控 Jenkins 日志大小的东西。

例如,如果日志大小超过200MB(作业为运行时),我想自动停止构建。

如果您开发了这样的 shell 脚本或 Jenkins 插件,您可以分享您的解决方案吗?

谢谢:)

您可以使用 Logfilesizechecker Plugin:

This plugin monitors the size of the output file of a build and aborts the build if the log file gets too big.

或者,如果这对运行时也有影响,Build-timeout Plugin:

This plugin allows you to automatically abort a build if it's taking too long. Once the timeout is reached, Jenkins behaves as if an invisible hand has clicked the "abort build" button.