如何在Jenkins上停止无法阻止的僵尸作业而无需重新启动服务器? [英] How to stop an unstoppable zombie job on Jenkins without restarting the server?

查看:132
本文介绍了如何在Jenkins上停止无法阻止的僵尸作业而无需重新启动服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的Jenkins服务器有一个已经运行了三天的工作,但是什么也没做.单击角落中的小X不会执行任何操作,并且控制台输出日志也不会显示任何内容.我检查了我们的构建服务器,该工作实际上似乎根本没有运行.

Our Jenkins server has a job that has been running for three days, but is not doing anything. Clicking the little X in the corner does nothing, and the console output log doesn't show anything either. I've checked on our build servers and the job doesn't actually seem to be running at all.

是否可以通过编辑某些文件或锁或其他内容来告诉jenkins作业已完成"?由于我们有很多工作,因此我们实际上并不想重启服务器.

Is there a way to tell jenkins that the job is "done", by editing some file or lock or something? Since we have a lot of jobs we don't really want to restart the server.

推荐答案

转到管理Jenkins">脚本控制台"以在服务器上运行脚本以中断挂起的线程.

Go to "Manage Jenkins" > "Script Console" to run a script on your server to interrupt the hanging thread.

您可以使用Thread.getAllStackTraces()获取所有活动线程,并中断正在挂起的线程.

You can get all the live threads with Thread.getAllStackTraces() and interrupt the one that's hanging.

Thread.getAllStackTraces().keySet().each() {
  t -> if (t.getName()=="YOUR THREAD NAME" ) {   t.interrupt();  }
}

更新:

以上使用线程的解决方案可能不适用于最新的Jenkins版本.要中断冻结的管道,请参考解决方案(通过

The above solution using threads may not work on more recent Jenkins versions. To interrupt frozen pipelines refer to this solution (by alexandru-bantiuc) instead and run:

Jenkins.instance.getItemByFullName("JobName")
                .getBuildByNumber(JobNumber)
                .finish(
                        hudson.model.Result.ABORTED,
                        new java.io.IOException("Aborting build")
                );

这篇关于如何在Jenkins上停止无法阻止的僵尸作业而无需重新启动服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆