Jenkins 在构建和 post-构建之间挂起

Jenkins hangs between build and post-build

将 Jenkins 更新到版本 2.156(从版本 1.6)后,我们的一些构建作业在完成之后和移动到 post-构建操作之前卡住了。作业本身在 5 分钟内完成(与之前相同),然后挂起 5-10 分钟再继续。

我设法将范围缩小到:

"Executor #10 for master : executing 03_masa #4390" Id=34464 Group=main TIMED_WAITING
    at java.lang.Thread.sleep(Native Method)
    at hudson.util.ProcessTree$WindowsOSProcess.killSoftly(ProcessTree.java:560)
    at hudson.util.ProcessTree$WindowsOSProcess.killRecursively(ProcessTree.java:520)
    at hudson.util.ProcessTree$Windows.killAll(ProcessTree.java:666)
    at hudson.Launcher$LocalLauncher.kill(Launcher.java:955)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:510)
    at hudson.model.Run.execute(Run.java:1810)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)

可找到参考代码here(自版本 2.141 起存在)。

threadDump #1, threadDump #2

我们能做点什么吗?

2.141 引入了 2 分钟的进程终止等待时间(这似乎与构建期间创建的进程数成倍增加)

https://github.com/jenkinsci/jenkins/commit/d8eac92ee9a1c19bf145763589f1c152607bf3ed

不确定为什么 killSoftly 不起作用,但您可以配置超时

在您的 jenkins.xml 中,您可以将其添加到 /service/arguments 元素(在 -jar 之前),如下所示:

-DSoftKillWaitSeconds=0

这样做并重新启动 jenkins 后,您应该能够在 /systemInfo

下找到您的 SoftKillWaitSeconds 设置

并且您的构建时间应该恢复正常