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

相关推荐
阿里云大数据AI技术1 天前
阿里云 EMR AI 助手正式发布:从问答工具到全栈智能运维助手
运维·人工智能
SkyWalking中文站2 天前
认识 Horizon UI · 6/17:Trace 探索器
运维·监控·自动化运维
火车叼位2 天前
写给初级开发者:SSL、SSH、HTTPS 与证书体系全解析
运维
小猿姐3 天前
唯品会大规模数据库云原生实践:基于 KubeBlocks 管理数千实例的统一运维之路
运维·elasticsearch·云原生
SkyWalking中文站3 天前
认识 Horizon UI · 5/17:3D 基础设施地图
运维·监控·自动化运维
SkyWalking中文站4 天前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
雪梨酱QAQ4 天前
Kubeneters HA Cluster部署
运维
江华森4 天前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森4 天前
Matplotlib 数据绘图基础入门
运维
江华森4 天前
NumPy 数值计算基础入门
运维