How does Jenkins decide where to run a build when several nodes match?
AdvancedConceptArchitecture, executors & JENKINS_HOME
Answer
The default LoadBalancer uses consistent hashing on the job name to prefer the node the job last ran on (to reuse the workspace and caches), falling back to other matching nodes with free executors. If none are free, the item waits; cloud plugins observe the queue through NodeProvisioner and provision new nodes based on load statistics. Plugins like Least Load or Throttle Concurrent Builds change the strategy. With Kubernetes agents the hashing barely matters because every build gets a fresh pod.
More on Architecture, executors & JENKINS_HOME
What are the main components of a Jenkins installation?BeginnerWhat is the difference between a node, an agent and an executor?BeginnerWhy should the built-in node have 0 executors?BeginnerWhat is `JENKINS_HOME` and what are its most important contents?BeginnerWhat happens if you lose the `secrets/` directory but keep `credentials.xml`?AdvancedHow does an agent communicate with the controller?Intermediate