I have what seems to be a catch-22 situation with a set of build configurations I'm managing. Our TeamCity environment is completely virtualised, with each build agent running in a separate VM. This set of build configurations deletes the build agent VMs on a weekly basis, and then recreates them from a number of different templates. The way I have it configured is as follows:
- Run "Delete Existing Build Agents". This removes all build agent VMs, except for the agent currently running the job.
- Run each of the following in parallel:
- "Regenerate Build Agents (template 1)"
- "Regenerate Build Agents (template 2)"
- "Regenerate Build Agents (template 3)"
- "Regenerate Build Agents (template 4)"
My initial configuration had the four "Regenerate Build Agents" configurations set up with a Finish Build trigger on "Delete Existing Build Agents", but unfortunately this lead to problems where one of the build configurations would try to create an agent with the same name as the one left over from step 1. To get around this, I reconfigured the "Regenerate Build Agent" configurations to use snapshot dependencies on "Delete Existing Build Agents". This worked fine for the first week or two.
Unfortunately this week the job failed because the "Delete Existing Build Agents" configuration hadn't run - the dependencies were configured to only trigger it if there was no suitable build available. With no changes made in the last week to the scripts governing this process, last week's run was deemed suitable, and no agents were deleted. As a consequence, the four "Regenerate Build Agents" configurations each failed because they were trying to create agents that already existed.
I don't believe that I can configure this dependency to run the "Delete Existing Build Agents" configuration regardless of whether or not there is a suitable build, as I believe this will result in four runs of this configuration being triggered. Potentially, that could be disastrous: we might end up with no agents left at all.
What I am looking for is a way to reconfigure these builds to run so that just one "Delete Existing Build Agents" is run for all four of the "Regenerate Build Agents", that this configuration is always run, and for the whole thing to run on a weekly schedule. Is it possible to configure these build configurations in this manner? Perhaps I need to restructure the configurations to support this chain better - if so, how?
Thanks in advance