Demands

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, run and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Use demands to make sure that the capabilities your pipeline needs are present on the agents that run it. Demands are asserted automatically by tasks or manually by you.

Note

Demands are only applicable when your pipeline runs on self-hosted agents.

Task demands

Some tasks won't run unless one or more demands are met by the agent. For example, the Visual Studio Build task demands that msbuild and visualstudio are installed on the agent.

Manually entered demands

You might need to use self-hosted agents with special capabilities. For example, your pipeline may require SpecialSoftware on agents in the Default pool. Or, if you have multiple agents with different operating systems in the same pool, you may have a pipeline that requires a Linux agent.

To add a single demand to your YAML build pipeline, add the demands: line to the pool section.

pool:
  name: Default
  demands: SpecialSoftware # Check if SpecialSoftware capability exists

Or if you need to add multiple demands, add one per line.

pool:
  name: Default
  demands:
    - SpecialSoftware # Check if SpecialSoftware capability exists
    - Agent.OS -equals Linux # Check if Agent.OS == Linux

For multiple demands:

pool:
  name: MyPool
  demands:
  - myCustomCapability   # check for existence of capability
  - agent.os -equals Darwin  # check for specific string in capability

For more information and examples, see YAML schema - Demands.

Register each agent that has the capability.

  1. In your web browser, navigate to Agent pools:

    1. Choose Azure DevOps, Organization settings.

      Organization settings

    2. Choose Agent pools.

      Choose Manage pools

    1. Choose Azure DevOps, Collection settings.

      Organization settings

    2. Choose Agent pools.

      Choose Manage pools

    1. Navigate to your project and choose Settings (gear icon) > Agent Queues.

      Choose settings, Agent Queues

    2. Choose Manage pools.

      Choose Manage pools

    1. Navigate to your project and choose Settings (gear icon) > Agent Queues.

      Choose settings, Agent Queues

    2. Choose Manage pools.

      Choose Manage pools

    1. Navigate to your project and choose Manage project (gear icon).

      Manage project

    2. Choose Control panel.

      Choose Control panel

    3. Select Agent pools.

      Agent pools tab

  2. Navigate to the capabilities tab for the agent:

    1. From the Agent pools tab, select the desired agent pool.

      Choose Manage pools

    2. Select Agents and choose the desired agent.

      Select Agents and choose the desired agent

    3. Choose the Capabilities tab.

      Agent capabilities tab

    1. From the Agent pools tab, select the desired pool.

      Choose Manage pools

    2. Select Agents and choose the desired agent.

      Select Agents and choose the desired agent

    3. Choose the Capabilities tab.

      Agent capabilities tab

    Select the desired agent, and choose the Capabilities tab.

    Agent capabilities tab

    Select the desired agent, and choose the Capabilities tab.

    Agent capabilities tab

    From the Agent pools tab, select the desired agent, and choose the Capabilities tab.

    Agent capabilities tab

  3. Add something like the following entry:

First box Second box
SpecialSoftware C:\Program Files (x86)\SpecialSoftware

Tip

When you manually queue a build you can change the demands for that run.