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

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

    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.

    0 讨论(0)
  • 2020-11-27 09:40

    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.
    0 讨论(0)
  • 2020-11-27 09:41

    I guess it is too late to answer but my help some people.

    1. Install the monitoring plugin. (http://wiki.jenkins-ci.org/display/JENKINS/Monitoring)
    2. Go to jenkinsUrl/monitoring/nodes
    3. Go to the Threads section at the bottom
    4. Click on the details button on the left of the master
    5. Sort by User time (ms)
    6. Then look at the name of the thread, you will have the name and number of the build
    7. Kill it

    I don't have enough reputation to post images sorry.

    Hope it can help

    0 讨论(0)
  • 2020-11-27 09:41

    None of these solutions worked for me. I had to reboot the machine the server was installed on. The unkillable job is now gone.

    0 讨论(0)
  • 2020-11-27 09:44

    If you have an unstoppable Pipeline job, try the following:

    1. Abort the job by clicking the red X next to the build progress bar
    2. Click on "Pause/resume" on the build to pause
    3. Click on "Pause/resume" again to resume the build

    Jenkins will realize that the job should be terminated and stops the build

    0 讨论(0)
  • 2020-11-27 09:44

    Enter the blue-ocean UI. Try to stop the job from there.

    0 讨论(0)
提交回复
热议问题