Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign specific agent on Azure DevOps YAML Pipelines

I am trying to assign a specific agent on my agent pool but I don't know how to do it. Does anyone know it?

I tried with this but doesn't work:

- stage: Deploy
  pool: alm-aws-pool
    agent.name: deploy-05-agent1
like image 218
Dàniel Hernández Avatar asked Jul 01 '20 11:07

Dàniel Hernández


People also ask

How do I specify agent pool in YAML?

For more information, see the YAML schema for pools. To choose a pool and agent in the classic editor, navigate to the pipeline settings, select the desired Agent pool, and then the desired image from the Agent Specification drop-down. The default Agent Specification is windows-2019.

How do I deploy to Azure using YAML?

You can deploy to Azure using YAML pipelines instead of classic Release pipelines. You can also see that this uses a Microsoft hosted build agent ubuntu-latest. This is to boot-strap the environment. After this pipeline runs, the self-hosted agent pool you created will have multiple build agents available for other pipelines to use.

How do I use Azure DevOps CLI with a YAML pipeline?

If you wish to use Azure DevOps CLI with a YAML pipeline, you can use the following example to understand how YAML can be used to install Azure CLI, add the Azure DevOps extension, and run Azure DevOps CLI commands. The steps in this article show how to authenticate with Azure DevOps and run az devops commands using the Azure DevOps CLI extension.

How do I create an agent in azure pipelines?

The agents must have connectivity to the target on-premises environments, and access to the Internet to connect to Azure Pipelines or Team Foundation Server, as shown in the following schematic. To register an agent, you need to be a member of the administrator role in the agent pool.

What is the issue number for Azure pipelines YAML?

· Issue #353 · microsoft/azure-pipelines-yaml · GitHub Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.


2 Answers

The pool name needs to add to the name field, then you could add demands. You may try the following Yaml Code:

stages:
- stage: Deploy
  pool: 
   name: AgentPoolName(e.g. alm-aws-pool)
   demands:
    - agent.name -equals Agentname (e.g. deploy-05-agent1)
  jobs:
  - job: BuildJob
    steps:
    - script: echo Building!

Please check if it could work.

Hope this helps.

like image 126
Kevin Lu-MSFT Avatar answered Oct 11 '22 02:10

Kevin Lu-MSFT


Use demands

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml

- stage: Deploy   
    pool: alm-aws-pool
    demands:
    - agent.name -equals deploy-05-agent1
like image 42
Kontekst Avatar answered Oct 11 '22 01:10

Kontekst