我们的Jenkins服务器有一个已经运行了三天的作业,但是没有做任何事情。单击角落里的小X没有任何作用,控制台输出日志也没有显示任何内容。我在我们的构建服务器上检查过,该作业实际上似乎根本没有在运行。
有没有办法告诉jenkins工作已经“完成”了,比如编辑一些文件或锁之类的?因为我们有很多任务,所以我们并不想重新启动服务器。
我们的Jenkins服务器有一个已经运行了三天的作业,但是没有做任何事情。单击角落里的小X没有任何作用,控制台输出日志也没有显示任何内容。我在我们的构建服务器上检查过,该作业实际上似乎根本没有在运行。
有没有办法告诉jenkins工作已经“完成”了,比如编辑一些文件或锁之类的?因为我们有很多任务,所以我们并不想重新启动服务器。
当前回答
有同样的问题,但没有堆栈线程。我们使用Jenkins控制台中的这个片段删除了作业。将jobname和build dnumber替换为您的。
def jobname = "Main/FolderName/BuildDefinition"
def buildnum = 6
Jenkins.instance.getItemByFullName(jobname).getBuildByNumber(buildnum).delete();
其他回答
我编写的一个名为jkillthread的实用程序可以用来停止任何Java进程中的任何线程,只要您能够以相同的帐户登录到运行该服务的机器。
进入蓝海用户界面。 试着从那里阻止他。
在https://my-jenkins/script上使用脚本控制台
import hudson.model.Job
import org.jenkinsci.plugins.workflow.job.WorkflowRun
Collection<Job> jobs = Jenkins.instance.getItem('My-Folder').getAllJobs()
for (int i = 0; i < jobs.size(); i++) {
def job = jobs[i]
for (int j = 0; j < job.builds.size(); j++) {
WorkflowRun build = job.builds[j]
if (build.isBuilding()) {
println("Stopping $job ${build.number}")
build.setResult(Result.FAILURE)
}
}
}
非常简单的解决方案
我看到这个问题的原因是页面上不正确的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
使用截图作为参考
我有很多僵尸工作,所以我使用下面的脚本:
for(int x = 1000; x < 1813; x = x + 1) {
Jenkins .instance.getItemByFullName("JOBNAME/BRANCH")
.getBuildByNumber(x)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"))
}