Interview Prep/Jenkins/Scripted pipeline, Groovy & CPS

Why is `sleep` or `waitUntil` inside an agent block wasteful?

BeginnerConceptScripted pipeline, Groovy & CPS
Answer

While a build sleeps inside node {} or a stage with an agent, it holds the executor and, on Kubernetes, keeps the pod with its CPU and memory requests reserved. Waiting for an external system (a deployment, an approval, a long test run elsewhere) should happen outside agent blocks when possible, or use webhooks such as waitForQualityGate that pause cheaply on the controller.

All Jenkins questions Roadmap: Jenkins

More on Scripted pipeline, Groovy & CPS