我们的Jenkins服务器有一个已经运行了三天的作业,但是没有做任何事情。单击角落里的小X没有任何作用,控制台输出日志也没有显示任何内容。我在我们的构建服务器上检查过,该作业实际上似乎根本没有在运行。

有没有办法告诉jenkins工作已经“完成”了,比如编辑一些文件或锁之类的?因为我们有很多任务,所以我们并不想重新启动服务器。


当前回答

非常简单的解决方案

我看到这个问题的原因是页面上不正确的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

使用截图作为参考

其他回答

你可以复制作业,然后删除旧的。如果你丢失了旧的构建日志没有关系的话。

Alexandru Bantiuc的回答很好地让我停止了构建,但我的执行人仍然很忙。我可以使用以下命令清除繁忙的执行程序状态

server_name_pattern = /your-servers-[1-5]/
jenkins.model.Jenkins.instance.getComputers().each { computer ->
  if (computer.getName().find(server_name_pattern)) {
    println computer.getName()
    execList = computer.getExecutors()      
    for( exec in execList ) {
      busyState = exec.isBusy() ? ' busy' : ' idle'
      println '--' + exec.getDisplayName() + busyState
      if (exec.isBusy()) {
        exec.interrupt()
      }
    }
  }
}

我有很多僵尸工作,所以我使用下面的脚本:

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"))
}

我看了Jenkins源代码,似乎我要做的是不可能的,因为停止一个作业似乎是通过线程中断完成的。我不知道为什么这个工作被搁置了。

编辑:

就业势不可挡的可能原因:

如果Jenkins陷入了无限循环,它就永远不能中止。 如果Jenkins在Java虚拟机中进行网络或文件I/O(例如长时间的文件复制或SVN更新),则不能中止。

我编写的一个名为jkillthread的实用程序可以用来停止任何Java进程中的任何线程,只要您能够以相同的帐户登录到运行该服务的机器。