Have integrated Jenkins with Atlassian Bitbucket where I trigger what we call "pre-merge" builds. This means once pull-requests are ready for merge we start a job that checks that they are really ready for merge. A failed build will prevent the merge.
Any change on the target branch, or the source branch will trigger a new build. Since there are several pull requests that wants to merge to the develop branch many jobs can be triggered simultanously causing 2-3 or even more build jobs to be queued at once.
We have 2 build slaves/agents that I have given the same label so they can be used simultanously to balance the load so to speak.
Now then, in the job, I have entered a restriction for where this job can execute in the "Label expression": 'label-that-sits-on-two-slaves'.
I have also entered a "Blocking jobs" -name like ABC* and then selecting the "block on node level" which leads me to believe that this would allow one of the "pre-merge" builds to use one of our agents and a second one to use the other slave and this seems to work for NON-PIPELINE jobs.
Doing the same for a pipeline job, where specifying:
does not work.
What is required to be able to automatically distribute a build-job on two or more agents simultanously and prevent them from running at the same time on the same agent using pipeline scripts?