Hello @thigg and welcome to this community.
Yes, your observation is correct, at least for me.
In Jenkins Pipeline, when you specify an agent at the top level and then again at the stage level, it requires two executor slots.
The first executor is for the main pipeline job, and the second executor is for the stage that has its own agent directive.
This can indeed lead to a deadlock situation if the number of available executors is less than the number of required executors.
In your case, if you have 4 executor slots and 4 jobs, each requiring 2 slots, they can stall each other (been there, done that).
One way to prevent this is to increase the number of executor slots. However, this might not be feasible if you have resource constraints.
Another way is to restructure your pipeline to use a single agent for the entire pipeline, instead of specifying an agent for each stage.
This would reduce the number of required executor slots to 1 per job.
Here’s an example:
// Your steps here
// Other stages
In this example, the Docker agent is specified at the top level, so it’s used for the entire pipeline. This means that each job only requires 1 executor slot. The drawback is that your agent should be able to address all steps, so have all the software installed, whatever the step may be.