Making Use of Demands and Capabilties on VSTS Build Agents

Hello!

I have recently been creating a pipeline in VSTS that will check if certain software/PowerShell Modules are installed on the box, and if it isn’t then install it. It’s a sort of a DSC/Chef/Puppet process done via VSTS so that I don’t have to configure the aforementioned software.

But I needed a way to target a specific build agent to run this build on; specifying an agent pool is no good as it will deploy on any in that pool. I did think of creating a pool specifically to target, but this requires configuring, recongiuring, and then unconfiguring back to what it was, which is sounds like a tedious way to do things.

What I can actually use is a thing called “Demands” on the build; this scans a build agent of it’s Capabilities. Capabilities area bit of a misnomer in the fact that it is not only software installed, but also other system information, such as build agent name.

BuildAgentCapabilities

Which is exactly what we can use to filter the build to run on a specific build agent. So when we want to kick off a build, we can switch to the “Demands” tab, add “Agent.Name” and specify the build agent we want to run the build on.

SpecificBuildAgent

We can take this further if we wish by grouping build agents together within a pool by creating a user capability and using demands to filter in or out those build agents based on the value that we assign the capability. What is a shame is that we are unable to create capabilities outside of the UI; or at least I have been unable to do this any other way…