我可以一次性禁用 Hudson 的自动计划构建吗?
我们有一个大型 Hudson 设置,其中有许多计划的构建一直在运行。 目前,我正在尝试让一个构建正常工作,但有时我必须等待预定的构建进入队列。 有没有办法禁用所有计划的构建,以便我可以专注于麻烦的构建,而无需调整每个单独构建的“cron”设置?
We have a large Hudson set up with many scheduled builds running all the time. Currently I'm trying to get one build to work properly, but I have to occasionally wait when a scheduled build enters the queue. Is there a way to disable all the scheduled builds so I can concentrate on my troublesome build, without adjusting the "cron" settings of each individual build?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
对类似内容的搜索让我想到了这个问题,我意识到 Michael Donohue 的答案(以及他贡献的插件)还有另一个好处。
通过“配置切片”,可以轻松地一次性禁用部分作业。 这正是我暂时禁用 8 个相关工作中的 7 个所需要的,这样我就可以在 8 号工作。 谢谢迈克尔!
A search for something similar brought me to this question, and I realized there's another benefit of Michael Donohue's answer (and the plugin he contributed).
With "Configuration Slicing," it's easy to disable a subset of your jobs all at once. That's exactly what I needed to temporarily disable 7 of 8 related jobs so I could work on the 8th. Thanks Michael!
我没有看到直接的方法来做到这一点,但您可以编写一些更新所有作业的 config.xml 的内容。
在 hudson 的每个作业目录中,都有一个 config.xml。 <项目> 有一个名为“disabled”的元素,您可以将其更新为“true”,从而禁用该构建。
不太理想,但是一旦您有了脚本来遍历目录并更改禁用的值,您就可以随时使用它。
I don't see a direct way to do it, but you could write something that updates the config.xml for all jobs.
In each job's directory in hudson, there's a config.xml. The <project> has an element called disabled that you could update to true, thereby disabling that build.
Not ideal, but once you have the script to walk a directory and change the value of disabled, you can always use it.
告诉它准备关闭。
从 OP 编辑 (banjollity)
它并不完美,但我认为这是一个合理的“默认安装的几次鼠标点击解决方案”类型的解决方案,因此是公认的答案。
Tell it to prepare to shut down.
Edit from OP (banjollity)
It's not perfect, but I think this is a reasonable "few mouse clicks solution with a default install" kind of solution, hence the accepted answer.
我提供的'配置切片'插件允许您修改同时许多作业的 cron 设置。 这应该允许您进行所需的批量更改。
The 'configuration slicing' plugin I contributed allows you to modify the cron settings of many jobs simultaneously. This should allow you to make the bulk changes you want.
根据 Mikezx6r 的建议,我想出了一种快速方法来禁用与特定字符串匹配的所有构建:
[user@server jobs] $ for i in *build_name*; 执行 sed -is/"disabled>false"/"disabled>true/" $i/config.xml;
您还可以在“for”循环中迭代特定的构建名称:
[user@server jobs] $ for i in build1 build2 build3; 执行 sed -is/"disabled>false"/"disabled>true/" $i/config.xml;
你可以先测试它,看看它会做什么,方法是在 sed 之前添加一个“echo”:
[user@server jobs] $ for i in build1 build2 build3; 执行 echo sed -is/"disabled>false"/"disabled>true/" $i/config.xml;
相反,您可以通过切换 sed 脚本来重新启用所有匹配的作业:
[user@server jobs] $ for i in build1 build2 build3; 执行 sed -is/"disabled>true"/"disabled>false/" $i/config.xml; 完成
Expanding upon Mikezx6r's suggestion, I just came up with a quick method to disable all builds matching a certain string:
[user@server jobs] $ for i in *build_name*; do sed -i s/"disabled>false"/"disabled>true/" $i/config.xml; done
You could also iterate through specific build names in the "for" loop:
[user@server jobs] $ for i in build1 build2 build3; do sed -i s/"disabled>false"/"disabled>true/" $i/config.xml; done
You can test it first to see what it will do by putting an "echo" before sed:
[user@server jobs] $ for i in build1 build2 build3; do echo sed -i s/"disabled>false"/"disabled>true/" $i/config.xml; done
Conversely, you can re-enable all matching jobs by switching around the sed script:
[user@server jobs] $ for i in build1 build2 build3; do sed -i s/"disabled>true"/"disabled>false/" $i/config.xml; done
这可以使用 jenkins 控制台来完成。 它运行常规脚本并执行几乎所有操作。
以下脚本迭代所有项目。 检查它是否有TimerTrigger。(也可以扩展对其他触发器的检查)
This can be done using jenkins Console. It runs groovy script and do almost anything.
Following script iterates through all projects. Check if it has TimerTrigger.(One can extend this check of other triggers as well)