如何在池需求中使用矩阵变量?

问题描述 投票:7回答:1

对于Azure Pipelines yaml文件,我要在特定池中的每个代理上一次运行一组任务。当我查看工作策略矩阵时,它看起来是一个很好的解决方案,但目前无法获取我为此使用的变量。]​​>

与管道有关的管道yaml文件是此部分:

resources:
- repo: self

trigger: none

jobs:
- job: RunOnEveryAgent
  strategy:
    maxParallel: 3
    matrix:
      agent_1:
        agentName: Hosted Agent
      agent_2:
        agentName: Hosted VS2017 2
      agent_3:
        agentName: Hosted VS2017 3
  pool:
    name: Hosted VS2017
    demands:
    - msbuild
    - visualstudio
    - Agent.Name -equals $(agentName)

  steps:
  - (etc.)

使用此脚本,我尝试设置一个矩阵以在池中的三个代理中的每个代理上运行一次。但是,当我尝试在需求列表中引用该代理时,它不会选择它。实际的错误消息如下:

[[错误1]在满足指定要求的托管VS2017池中找不到代理:

msbuild

visualstudio

Agent.Name-等于$(agentName)

Agent.Version -gtVersion 2.141.1

如果我对代理人名称进行硬编码,则它[[确实

有效: demands: - msbuild - visualstudio - Agent.Name Hosted VS2017 3
是否支持在池需求中使用这些变量?还是应该使用其他变量或表达式?

对于Azure Pipelines yaml文件,我要在特定池中的每个代理上一次运行一组任务。当我查看工作策略矩阵时,它看起来是一个很好的解决方案,但目前...

azure-devops azure-pipelines azure-pipelines-build-task
1个回答
0
投票
其中一些作业不支持变量,因为变量的扩展顺序。
© www.soinside.com 2019 - 2024. All rights reserved.