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

前端 未结 27 1619
南旧
南旧 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:47

    Go to "Manage Jenkins" > "Script Console" to run a script on your server to interrupt the hanging thread.

    You can get all the live threads with Thread.getAllStackTraces() and interrupt the one that's hanging.

    Thread.getAllStackTraces().keySet().each() {
      t -> if (t.getName()=="YOUR THREAD NAME" ) {   t.interrupt();  }
    }
    

    UPDATE:

    The above solution using threads may not work on more recent Jenkins versions. To interrupt frozen pipelines refer to this solution (by alexandru-bantiuc) instead and run:

    Jenkins.instance.getItemByFullName("JobName")
                    .getBuildByNumber(JobNumber)
                    .finish(
                            hudson.model.Result.ABORTED,
                            new java.io.IOException("Aborting build")
                    );
    

提交回复
热议问题