我可以一次性禁用 Hudson 的自动计划构建吗?

发布于 2024-08-01 20:14:50 字数 131 浏览 2 评论 0原文

我们有一个大型 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

迎风吟唱 2024-08-08 20:14:50

对类似内容的搜索让我想到了这个问题,我意识到 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!

故事还在继续 2024-08-08 20:14:50

我没有看到直接的方法来做到这一点,但您可以编写一些更新所有作业的 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.

幽梦紫曦~ 2024-08-08 20:14:50

告诉它准备关闭。


从 OP 编辑​​ (banjollity)
它并不完美,但我认为这是一个合理的“默认安装的几次鼠标点击解决方案”类型的解决方案,因此是公认的答案。

  1. 排队作业
  2. 告诉 Hudson 准备关闭。 这可以防止其他作业同时运行。
  3. 诊断我的工作中的错误,提交可能修复它的新代码。 (我喜欢我的工作)。
  4. 取消哈德逊关闭。
  5. 转到步骤 1。

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.

  1. Queue up a job
  2. Tell Hudson to prepare to shut down. This prevents other jobs being run in the meantime.
  3. Diagnose faults with my job, commit new code that might fix it. (I love my job).
  4. Cancel Hudson shut down.
  5. Goto step 1.
≈。彩虹 2024-08-08 20:14:50

我提供的'配置切片'插件允许您修改同时许多作业的 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.

半﹌身腐败 2024-08-08 20:14:50

根据 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

罪歌 2024-08-08 20:14:50

这可以使用 jenkins 控制台来完成。 它运行常规脚本并执行几乎所有操作。

以下脚本迭代所有项目。 检查它是否有TimerTrigger。(也可以扩展对其他触发器的检查)

import hudson.model.Hudson
import hudson.model.Project
import hudson.triggers.TimerTrigger
import hudson.triggers.Trigger
import hudson.triggers.TriggerDescriptor

//All the projects on which we can apply the getBuilders method
def allProjects = Hudson.instance.items.findAll { it instanceof Project }
def projectsToWorkOn = [];
allProjects.each { Project project ->
    Map<TriggerDescriptor, Trigger> triggers =
            project.getTriggers();
    triggers.each { trigger ->

        if (trigger.value instanceof TimerTrigger) {
            projectsToWorkOn.push(project)


        }

    }
}


projectsToWorkOn
        .each { Project project ->

    project.disable();
    project.save()
}

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)

import hudson.model.Hudson
import hudson.model.Project
import hudson.triggers.TimerTrigger
import hudson.triggers.Trigger
import hudson.triggers.TriggerDescriptor

//All the projects on which we can apply the getBuilders method
def allProjects = Hudson.instance.items.findAll { it instanceof Project }
def projectsToWorkOn = [];
allProjects.each { Project project ->
    Map<TriggerDescriptor, Trigger> triggers =
            project.getTriggers();
    triggers.each { trigger ->

        if (trigger.value instanceof TimerTrigger) {
            projectsToWorkOn.push(project)


        }

    }
}


projectsToWorkOn
        .each { Project project ->

    project.disable();
    project.save()
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文