Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

Today we are going to discuss pool, demands, capabilities, and agent variables in Azure Pipeline. When you create an Azure Pipeline, you need to define the place where the pipeline will get executed. Using pool, you can define in which server (agent) your pipeline will get executed.

What is Azure Pipelines agents?

To build your code or deploy your software using Azure Pipelines, you need at least one agent. As you add more code and people, you’ll eventually need more. When your pipeline runs, the system begins one or more jobs. An agent is computing infrastructure with installed agent software that runs one job at a time.

  • Microsoft-hosted agents: If your pipelines are in Azure Pipelines, then you’ve got a convenient option to run your jobs using a Microsoft-hosted agent. With Microsoft-hosted agents, maintenance and upgrades are taken care of for you.
  • Self-hosted agents: An agent that you set up and manage on your own to run jobs is a self-hosted agent. You can use self-hosted agents in Azure Pipelines or Team Foundation Server (TFS). Self-hosted agents give you more control to install dependent software needed for your builds and deployments. Also, machine-level caches and configuration persist from run to run, which can boost speed.

What is Azure Pipelines agent pools?

Instead of managing each agent individually, you organize agents into agent pools. When you configure an agent, it is registered with a single pool, and when you create a pipeline, you specify which pool the pipeline uses. When you run the pipeline, it runs on an agent from that pool that meets the demands of the pipeline.

Pool: The pool keyword specifies which pool to use for a job of the pipeline. You can specify a pool at the pipeline, stage, or job level. The pool specified at the lowest level of the hierarchy is used to run the job.

Demand: The demand keyword is used to check if your agent meets a certain capability. Demands allows you to execute your pipeline based on certain conditions (capability) that is met in your agent. For example, suppose you have two agents with same OS but with different Python version, you can create a custom capability for Python version and assign to your agent and use that capability with demand in your pipeline config file to execute your pipeline in one of the agents which meets the Python version required by your pipeline.

Capability: Certain features of the agent that you can use as condition with demand to execute your pipeline on a specific agent based on some condition.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Prerequisites:

Step 1: Setup a new Azure DevOps project for this demo.

Step 2: Microsoft-Hosted agent.

If you do not define any pool configuration in your Azure pipeline config file, your pipeline will get executed in a Microsoft-hosted agent.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Next, we will define pool configuration to use Microsoft-hosted agents.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Observe: We have defined the pool keyword in pipeline, stage and job levels.

Get the latest Microsoft-hosted agents name using this link.

Next, we will use a self-hosted agent to explain demand and capabilities.

Step 3: Self-hosted agent.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Next, we will add a capability in our self-hosted agent and use this capability in our Azure pipeline using demand.

Step 4: Create a custom self-hosted agent capability

Log in to Azure DevOps portal and navigate to self-hosted agent capability configuration and click “Add a new capability”.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Provide a name and value for the new capability and click “Add”.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Step 5: Demand and Capability.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Next, we will explore different agent variables available in Azure Pipeline.

Step 6: Agent variables.

Azure Pipeline Part 1 – Pool Demands Capabilities Agent Variables

Step 7: Clean up.

Hope you have enjoyed this article. To know more about Azure DevOps, please refer below official documentation

https://docs.microsoft.com/en-us/azure/devops/?view=azure-devops

Leave a Reply

Close Menu