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
The top answer almost worked for me, but I had one major problem: I had a very large number (~100) of zombie jobs due to a particularly poorly-timed Jenkins restart, so manually finding the job name and build number of each and every zombie job and then manually killing them was infeasible. Here's how I automatically found and killed the zombie jobs:
Jenkins.instance.getItemByFullName(multibranchPipelineProjectName).getItems().each { repository->
repository.getItems().each { branch->
branch.builds.each { build->
if (build.getResult().equals(null)) {
build.doKill()
}
}
}
}
This script loops over all builds of all jobs and uses getResult().equals(null)
to determine whether or not the job has finished. A build that's in the queue but not yet started will not be iterated over (since that build won't be in job.builds
), and a build that's finished already will return something other than null
for build.getResult()
. A legitimately running job will also have a build result of null
, so make sure you have no running jobs that you don't want to kill before running this.
The multiple nested loops are mainly necessary to discover every branch/PR for every repository in a Multibranch Pipeline project; if you're not using Multibranch Pipelines you can just loop over all your jobs directly with something like Jenkins.instance.getItems().each
.
Without having to use the script console or additional plugins, you can simply abort a build by entering /stop
, /term
, or /kill
after the build URL in your browser.
Quoting verbatim from the above link:
Pipeline jobs can by stopped by sending an HTTP POST request to URL endpoints of a build.
- <BUILD ID URL>/stop - aborts a Pipeline.
- <BUILD ID URL>/term - forcibly terminates a build (should only be used if stop does not work.
- <BUILD ID URL>/kill - hard kill a pipeline. This is the most destructive way to stop a pipeline and should only be used as a last resort.
I guess it is too late to answer but my help some people.
I don't have enough reputation to post images sorry.
Hope it can help
None of these solutions worked for me. I had to reboot the machine the server was installed on. The unkillable job is now gone.
If you have an unstoppable Pipeline job, try the following:
Jenkins will realize that the job should be terminated and stops the build
Enter the blue-ocean UI. Try to stop the job from there.