如何使用azure-pipelines.yml在Microsoft Azure CI管道中选择代理

时间:2020-05-31 15:31:05

标签: azure-devops continuous-integration

我有这个脚本:

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脚本?

enter image description here

1 个答案:

答案 0 :(得分:2)

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

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

在您的情况下,您可以使用Agent.NameAgent.ComputerName需求。