Why can't my pipeline task be completed?

I’m encountering an intermittent issue where a pipeline passes all stages successfully but hangs indefinitely at the final step:

end of pipeline


Normally, this message should immediately be followed by Finished: SUCCESS, but in these cases, the pipeline appears to freeze. Notably:

  1. The build page already shows SUCCESS status (despite the hang), leaving no option to terminate/kill the job—only “Delete” is available.
  2. After deleting one such build, I’m unsure whether pipeline resources (e.g., executors, temp files) were fully released, raising concerns about hidden resource leaks.

Steps to Reproduce (Low Probability):

  • Run pipelines repeatedly; issue occurs sporadically (~1/500 runs).
  • No clear pattern—fails randomly after all steps pass.

Expected Behavior:
After end of pipeline, Jenkins should:

  • Print Finished: SUCCESS promptly.
  • Fully release resources upon build completion/deletion.

It seems that someone reported this issue a year ago

I tried upgrading the pipeline-related plugins, but it didn’t work. Recently, it has recurred, about four or five times a week


Here’s an additional piece of information
The pipeline has ended for a day and the status has returned to “succeed”, but it will still be in the loading state. And based on past experience, as long as this build is not deleted, this loading state will continue and become a zombie task

I would suspect some RunListener that is not behaving well in it’s #onCompleted method and hangs.
You might want to look at the threaddump if you see there anything

I checked the stack status of Jenkins and found that 1,200 threads were in the TIMED_WAITING state. Is this the problem?

java.lang.Thread.getAllStackTraces().each { 
  thread, stack -> 
    println "\nThread: ${thread.name} (ID: ${thread.id}, State: ${thread.state})"
    stack.each { println "  at $it" } 
}
Thread: Computer.threadPoolForRemoting [#504201] (ID: 26043805, State: TIMED_WAITING)
  at java.base@21.0.2/jdk.internal.misc.Unsafe.park(Native Method)
  at java.base@21.0.2/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:410)
  at java.base@21.0.2/java.util.concurrent.LinkedTransferQueue$DualNode.await(LinkedTransferQueue.java:452)
  at java.base@21.0.2/java.util.concurrent.SynchronousQueue$Transferer.xferLifo(SynchronousQueue.java:194)
  at java.base@21.0.2/java.util.concurrent.SynchronousQueue.xfer(SynchronousQueue.java:233)
  at java.base@21.0.2/java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:336)
  at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1069)
  at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
  at java.base@21.0.2/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
  at java.base@21.0.2/java.lang.Thread.runWith(Thread.java:1596)
  at java.base@21.0.2/java.lang.Thread.run(Thread.java:1583)

Hi @mawinter69,I checked the threaddump. The status of “java.lang.Thread.State” is mostly TIMED_WAITING (parking)/TIMED_WAITING (sleeping). I’m not quite sure if this is what you mentioned. Or is there any other way to obtain more information? I still keep the scene of the question