Jenkins scheduling strategy

Hello!

I want to understand with more precision how Jenkins performs node selection for the node(…) statement in the context of running 1 job many times. I would like to take a look at docs/code, but I am unsure where to start and how to navigate the code base. From what I have seen so far, it seems that Jenkins will evaluate my label to get all available nodes and then prioritize running on the same node as it previously chose (for the same job).

My use case is that I want to select a node based on an expression of labels, but also give a sense of priority. I would want to tell jenkins to run on “A” if available, otherwise run on “B” and preserve this priority if there is a queue for both labels. Are there plugins or some groovy magic that can help me for this?

Thanks!

Based on a stackoverflow answer, I think that the closest available choice is the scoring load balancer plugin.