Azure DevOps更改代理程序池

时间:2020-05-06 15:17:50

标签: azure-devops

我正在尝试设置构建管道以在特定的代理程序池上运行。目前,它坚持要在“ Azure管道”池上工作:

Azure DevOps agent pools screen

但是,我无法更改构建管道的代理池(至少我不确定如何)。

我的YAML如下:

trigger:

- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: 'Pack the package'
  inputs:
    command: 'pack'
    configuration: 'Release'
    packagesToPack: 'NugetComponents/**/*.csproj'
    nobuild: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

我不确定是否需要在此处进行任何更改。我在用于配置管道应使用哪个代理bool的界面中找不到任何内容?

1 个答案:

答案 0 :(得分:2)

根据this doc about agent pools,“ Azure Pipelines”池包含各种Windows,Linux和macOS映像。

Azure Pipelines托管池替换了以前的托管池 具有映射到相应图像的名称。您的任何工作 在以前的托管池中具有的地址会自动重定向到 在新的Azure Pipelines托管池中正确映像。

因此,当您指定Microsoft托管的代理(例如Ubuntu-latest)时,管道将在“ Azure管道”池上运行。

更新

您可以在“池”字段中指定目标代理程序池。

这是Yaml的格式:

pool:
  name: string  
  demands: string 
  vmImage: string 

对于Microsoft托管的代理:您可以直接指定“ vmImage”。

例如:

pool:
  vmImage: 'ubuntu-16.04'

对于自托管代理,您可以指定代理池名称。

例如:

pool:
  name: Agent Pool name

这是有关specifying agent pool in Yaml的文档。