How to stop an unstoppable zombie job on Jenkins without restarting the server?

前端 未结 27 1601
南旧
南旧 2020-11-27 09:18

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 do

27条回答
  •  醉梦人生
    2020-11-27 09:45

    Recently I came across a node/agent which had one executor occupied for days by a build "X" of a pipeline job, although that jobs page claimed build "X" did not exist anymore (discarded after 10 subsequent builds (!), as configured in the pipeline job). Verified that on disk: build "X" was really gone.

    The solution: it was the agent/node which wrongly reported that the occupied executor was busy running build "X". Interrupting that executor's thread has immediately released it.

    def executor = Jenkins.instance.getNode('NODENAME').computer.executors.find {
        it.isBusy() && it.name.contains('JOBNAME')
    }
    
    println executor?.name
    if (executor?.isBusy()) executor.interrupt()
    

    Other answers considered:

    • The answer from @cheffe: did not work (see next point, and update below).
    • The answers with Thread.getAllStackTraces(): no matching thread.
    • The answer from @levente-holló and all answers with getBuildByNumber(): did not apply as the build wasn't really there anymore!
    • The answer from @austinfromboston: that came close to my needs, but it would also have nuked any other builds running at the moment.

    Update:
    I experienced again a similar situation, where a Executor was occupied for days by a (still existing) finished pipeline build. This code snippet was the only working solution.

提交回复
热议问题