jenkins清理僵尸任务和排队任务

步骤

进入 Manage Jenkins系统管理 然后点击 Script Console , 然后根据自己需求选择性执行后面的脚本

查看所有进程

bash 复制代码
Thread.getAllStackTraces().keySet().each() {
  t -> println("name:"+t.getName())
}

例如:

bash 复制代码
name:Thread-90
name:Scheduler-174573182-1
name:Thread-116
name:Thread-110
name:Thread-83
name:org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution [#52]
name:SCMTrigger [#10]

停止特定进程

bash 复制代码
Thread.getAllStackTraces().keySet().each() {
  t -> if (t.getName()=="刚才查出来的某条进程名字" ) {   t.interrupt();  }
}

删掉所有进程

bash 复制代码
Thread.getAllStackTraces().keySet().each() {
  t ->   t.interrupt(); 
}

清掉所有排队任务Build Queue

bash 复制代码
Jenkins.instance.queue.clear()

取消某个指定job

bash 复制代码
import hudson.model.*
 
def q = Jenkins.instance.queue
 
q.items.findAll { it.task.name.startsWith('JobName') }.each { q.cancel(it.task) }

参考

1. [jenkins]僵尸任务&排队任务清理
2. 终止Jenkins队列中某Job的所有排队任务
3. Jenkins: remove old builds with command line

相关推荐
i***512616 分钟前
Failed to restart nginx.service Unit nginx.service not found
运维·nginx
neo_will_mvp34 分钟前
IDC服务器故障排除思路
运维·服务器
8***848243 分钟前
Nginx代理到https地址忽略证书验证配置
运维·nginx·https
傲世(C/C++,Linux)1 小时前
Linux系统编程——TCP客户端
linux·运维·tcp/ip
SelectDB1 小时前
Apache Doris 在小米统一 OLAP 和湖仓一体的实践
运维·数据库·程序员
23124_801 小时前
网络管理-1
运维·服务器·前端
YongCheng_Liang1 小时前
Python实现PDF 转 JPG 批量转换工具
运维·python·pdf
S***26751 小时前
linux 设置tomcat开机启动
linux·运维·tomcat
g***96901 小时前
SQL Server 中行转列
运维·服务器