我们的Jenkins服务器有一个已经运行了三天的作业,但是没有做任何事情。单击角落里的小X没有任何作用,控制台输出日志也没有显示任何内容。我在我们的构建服务器上检查过,该作业实际上似乎根本没有在运行。
有没有办法告诉jenkins工作已经“完成”了,比如编辑一些文件或锁之类的?因为我们有很多任务,所以我们并不想重新启动服务器。
我们的Jenkins服务器有一个已经运行了三天的作业,但是没有做任何事情。单击角落里的小X没有任何作用,控制台输出日志也没有显示任何内容。我在我们的构建服务器上检查过,该作业实际上似乎根本没有在运行。
有没有办法告诉jenkins工作已经“完成”了,比如编辑一些文件或锁之类的?因为我们有很多任务,所以我们并不想重新启动服务器。
当前回答
第一个提议的解决方案非常接近。如果使用stop()而不是interrupt(),它甚至会杀死在groovy系统脚本中无休止地运行的失控线程。这将杀死任何构建,任何工作。 代码如下:
Thread.getAllStackTraces().keySet().each() {
if (it.name.contains('YOUR JOBNAME')) {
println "Stopping $it.name"
it.stop()
}
}
其他回答
如果你有一个Multibranch Pipeline-job(并且你是Jenkins-admin),在Jenkins脚本控制台中使用这个脚本:
Jenkins.instance
.getItemByFullName("<JOB NAME>")
.getBranch("<BRANCH NAME>")
.getBuildByNumber(<BUILD NUMBER>)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
从https://issues.jenkins - ci.org/browse/jenkins - 43020
如果你不确定作业的全名(路径)是什么,你可以使用下面的代码片段列出所有项的全名:
Jenkins.instance.getAllItems(AbstractItem.class).each {
println(it.fullName)
};
从https://support.cloudbees.com/hc/en-us/articles/226941767-Groovy-to-list-all-jobs
非常简单的解决方案
我看到这个问题的原因是页面上不正确的http链接,而不是应该停止工作的https。所有你需要做的是编辑onclick属性在html页面,通过以下
Open up a console log of the job (pipeline) that got hang Click whatever is available to kill the job (x icon, "Click here to forcibly terminate running steps" etc) to get "Click here to forcibly kill entire build" link visible (it's NOT gonna be clickable at the moment) Open the browser's console (use any one of three for chrome: F12; ctrl + shift + i; menu->more tools->developer tools) Locate "Click here to forcibly kill entire build" link manually or using "select an element in the page" button of the console Double click on onclick attribute to edit its value Append s to http to have https Press enter to submit the changes Click "Click here to forcibly kill entire build" link
使用截图作为参考
如果你有一个不可阻挡的管道作业,试试下面的方法:
通过单击构建进度条旁边的红色X来终止作业 点击构建上的“Pause/resume”暂停 再次单击“暂停/恢复”以恢复构建
Jenkins将意识到该作业应该终止并停止构建
我看了Jenkins源代码,似乎我要做的是不可能的,因为停止一个作业似乎是通过线程中断完成的。我不知道为什么这个工作被搁置了。
编辑:
就业势不可挡的可能原因:
如果Jenkins陷入了无限循环,它就永远不能中止。 如果Jenkins在Java虚拟机中进行网络或文件I/O(例如长时间的文件复制或SVN更新),则不能中止。
进入蓝海用户界面。 试着从那里阻止他。