0
votes

I'm writing a c# activity to queue one build from another build. that bit's OK. However, I'm trying to add functionality that allwos me to select the specific build agent upon which the build should run. I've got it selecting the buildcontroller, but I can't seem to take it one step further by selecting the build agent. I'd prefer not to use tags. I can get the build agent after I've queued it, but I'd like to be able to select it before... even if that means my build sitting in a queue for the specific agent to become available.

The UI has the option to select a build agent when queuing a build, I'm trying to replicate it in C#.

Any help always appreciated.

Ta Padda

1
what is the specific reason for not using TAGS? TAGS are the quickest and easiest solution to your problem.Isaiah4110
Hi, Scenario: First part of the build does CI, its partner build does SQL tests. I have 4 build servers Build1, Build2... Each with 2 build agents Build1A/B,Build2A/B etc. When build starts on Build1A, I'd like the buddybuild to run on Build1B. Build1A will then check the status of Build1B, and if both OK, the gated check-in commits. I have a few branches, so need this isolation. I don't want the first part to run on 1A and the second on, 2B. TAGS can allow me select a group of build agents, i.e the 'B' agents, but won't let me select a build agent based on where its partner build is running.Jag Padda

1 Answers

0
votes

In your build definition, add a new Argument (with name say customagent) of type "AgentSettings", Direction "IN". Then in your MetaData add this argument "customagent", and add the related attributes like:

Parameter name = customagent Display name = "Build Agent" Category = "Build" (under what category should it display in your build definition" Description etc

Once you add this, when you edit your build definition, you should have a new set of variables to select the build agent where you want the particular build to happen. It can be set from UI. If you just want to edit this from code, you should be able to change the "BuildAgent" property way early in the build definition and that should help you.