如何在不重新启动服务器的情况下停止 Jenkins 上不可阻挡的僵尸作业? [英] How to stop an unstoppable zombie job on Jenkins without restarting the server?

查看:26
本文介绍了如何在不重新启动服务器的情况下停止 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.

有没有办法通过编辑一些文件或锁或其他东西来告诉詹金斯工作已经完成"?由于我们有很多工作,我们真的不想重新启动服务器.

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 版本.要中断冻结的管道,请参阅解决方案(来自 alexandru-bantiuc) 代替并运行:

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天全站免登陆