简体   繁体   English

仅在构建失败时如何清理Jenkins工作区

[英]How to clean Jenkins workspace only if build fails

In the interest of reducing build times I would like to only clean down the Jenkins job workspace if a build fails. 为了减少构建时间,我只想在构建失败时清理Jenkins作业工作区。 Is there of doing this using post build action? 是否可以使用构建后动作来执行此操作? Does Jenkins set a variable to the effect of 'BUILD FAILED' that can be read in a script that could be use in the post build action section of the job config? Jenkins是否将变量设置为“ BUILD FAILED”的效果,该变量可以在可以在作业配置的post build action部分中使用的脚本中读取?

Thanks in advance. 提前致谢。

Post-build Task plugin can read your console output and execute scripts if regex is found. 如果找到了正则表达式, 构建后的Task插件可以读取您的控制台输出并执行脚本。 When a build step fails, it will print "BUILD FAILED" into console output. 当构建步骤失败时,它将在控制台输出中打印“ BUILD FAILED”。

Configure post-build task to look for that, and execute the cleanup in that case. 配置构建后任务以查找该任务,然后在这种情况下执行清理。

Workspace Cleanup Plugin has an option just for that. Workspace Cleanup插件为此提供了一个选项。 Add its post build step, tick particular checkbox and it will clean only failed (unstable?) builds. 添加其构建后步骤,勾选特定复选框,它将仅清除失败(不稳定?)的构建。

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

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