You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins实例暂停需求咨询:保留队列且完成当前构建后暂停

实现Jenkins实例暂停(保留任务队列)的方案

Absolutely, this is totally achievable! Your exact use case—letting ongoing builds finish, pausing new build executions while keeping the queue intact (and even allowing new jobs to be added), then resuming later—is totally doable with either native Jenkins scripting or a lightweight plugin setup.

方法一:原生Jenkins脚本控制台(无需插件)

This is the most reliable and straightforward way, no extra plugins needed.

暂停实例(当前构建完成后停止执行新任务)

  1. 进入Jenkins的脚本控制台:Manage Jenkins → Script Console
  2. 运行以下Groovy脚本:
// 让所有节点停止接受新任务,当前运行的构建会继续完成
Jenkins.instance.nodes.each { node ->
  node.setAcceptingTasks(false)
}

Once you run this, all existing builds will finish normally, but no new builds from the queue will start. You can still submit new jobs to the queue—they'll just wait until you resume.

恢复实例(继续执行队列任务)

When you're ready to pick up where you left off, go back to the Script Console and run:

// 让所有节点重新接受新任务,队列顶部的任务会立即开始执行
Jenkins.instance.nodes.each { node ->
  node.setAcceptingTasks(true)
}

方法二:添加便捷按钮(可选优化)

If you don't want to mess with the Script Console every time, you can use the Scriptler Plugin to turn these scripts into one-click buttons:

  • Install the Scriptler Plugin from the Jenkins Plugin Manager
  • Create two new scripts (one for pause, one for resume) using the Groovy code above
  • You'll now have easy access to pause/resume buttons right from the Jenkins dashboard

为什么这比quietDown更适合你的需求

The built-in quietDown command is designed for safe restarts—it prevents new jobs from being added to the queue entirely, which doesn't match your need to keep accepting new queue items. The methods above let you keep the queue open while just pausing execution of queued jobs until you're ready.

内容的提问来源于stack exchange,提问作者Paulo Oliveira

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 12:42:36