How to stop a zombie job on Jenkins without restarting the server (#13277)

This commit is contained in:
Kapil Khandelwal 2023-01-12 03:04:34 +05:30 committed by GitHub
parent f396ff0341
commit dc5641200e
4 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,15 @@
pipeline {
agent any
stages {
stage('Infinite Loop') {
steps {
script {
while (true) {
println 'This is an infinite loop!'
Thread.sleep(10000)
}
}
}
}
}
}

View File

@ -0,0 +1,3 @@
Jenkins.instance.getItemByFullName("sampleZombieJob")
.getBuildByNumber(17)
.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));

View File

@ -0,0 +1,6 @@
Thread.getAllStackTraces().keySet().each() {
if (it.name.contains('sampleZombieJob')) {
println "Stopping $it.name"
it.interrupt()
}
}

View File

@ -0,0 +1,6 @@
Thread.getAllStackTraces().keySet().each() {
if (it.name.contains('sampleZombieJob')) {
println "Stopping $it.name"
it.stop()
}
}