[Jenkins] 强制退出job

首先进入 Jenkins 的 script console 页面:

script console 路径:manage jenkins -> manage nodes -> master -> script console

 

反正下面的脚本,都可以试一下

# 1

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

 

# 2

Thread
    .getAllStackTraces()
    .keySet()
    .each() {
        t -> println(t.getName());
    }

 

# 3

Thread
    .getAllStackTraces()
    .keySet()
    .each() {
      t -> if (t.getName().contains("JobName")) { println(t.getName()); t.stop(); }
    }

 

# 4

Thread
    .getAllStackTraces()
    .keySet()
    .each() {
      t -> if (t.getName().contains("JobName")) { println(t.getName()); t.interrupt(); }
    }

 

posted @ 2024-09-20 15:57  DavidHHuan  阅读(25)  评论(0编辑  收藏  举报