0

Simple scenario

Let's say I have a Jenkins job that uses 4 agents. In Jenkins, I have set up 10 agents. All the agents are identical, and they all carry the label "generic-agent". The Jenkins job treats them all the same as well, using the same label. The various agents don't necessarily finish their tasks all at the same time. I really don't want job #3 starting until there are a total of 4 available agents ready. If job #3 starts with just the 2 remaining agents, it will perform part of its tasks, but then wait for another 2 agents to become available. In this way, jobs 3, 4, 5, etc, will start to become staggered, and it will be hard to keep track of what jobs are really active vs waiting for resources, and how long a pipeline really takes to finish.

How can I tell jenkins to only start a job if 4 agents are completely available?

More complex scenario.

I have a jenkins job that uses 4 agents, but now they are differentiated. One stage uses an agent with the label "super-agent", while the other 3 stages use agents with the label "regular-agent". In my nodes, I have 2 super-agents and 8 regular-agents. How can I tell jenkins not to start the job until there is a complete group of 1 super-agent and 3 regular-agents available?

Seth Lutske
  • 9,154
  • 5
  • 29
  • 78
  • Maybe a stupidly simple solution that I can think of is. Acquire a node and rename it with the label that you generate in the pipeline. Execute pipeline, rename nodes back. The first `acquire nodes` will have a loop to acquire node. Agin, this is nowhere an efficient solution maybe. https://stackoverflow.com/questions/46933722/how-to-get-a-list-of-all-jenkins-nodes-assigned-with-label-including-master-node and to rename `node?.setLabelString(label)` – Ram Jul 13 '21 at 18:29
  • Would you mind elaborating on this a bit in an answer? I'm not sure what you mean by 'aqcuire a node' or `aqcuire node`. Can you explain how, if I have 10 nodes waiting to be used, I can use my jenkins pipeline script to do this? – Seth Lutske Jul 13 '21 at 18:49
  • yes. The link I shared explains how to list all available agents with label you need. And then rename that node. I will add a code snippet in a while. – Ram Jul 13 '21 at 19:04

0 Answers0