首页 > 解决方案 > 如何使用 azure-pipelines.yml 在 microsoft azure CI 管道中选择我的代理

问题描述

我有这个脚本:

trigger:
- master

pool:
  name: Mobile-Pool
  agent: 'MacMini3-AMS'
  vmImage: 'MacMini3-AMS'

steps:
- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx4096m'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'clean assembleDebug testDebugUnitTest'

# Bash
# Run a Bash script on macOS, Linux, or Windows
- task: Bash@3
  inputs:
    targetType: 'filePath'
    filePath: 'run-tests-on-emulator.sh'

- task: Gradle@2
  inputs:
    workingDirectory: ''
    gradleWrapperFile: 'gradlew'
    gradleOptions: '-Xmx4096m'
    publishJUnitResults: false
    testResultsFiles: '**/TEST-*.xml'
    tasks: 'connectedDebugAndroidTest'

我正在运行自己的本地硬件。我有一个MacMini3和一个MacMini2。MacMini2 无法正确编译,我想在 MacMini3 上运行。如何更改 yaml 脚本来做到这一点?

在此处输入图像描述

标签: azure-devopscontinuous-integration

解决方案


您应该使用Demands来确保您的管道所需的功能存在于运行它的代理上。

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

在您的场景中,您可以使用Agent.NameAgent.ComputerName需求。


推荐阅读