You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Azure Pipelines中用矩阵变量设置对象类型代理池?

解决Azure Pipelines矩阵中Pool配置的问题

矩阵变量仅支持标量值,无法直接在矩阵中定义对象类型的Pool配置,可通过条件表达式+标量平台标识的方式实现需求,具体配置如下:

- job: Test
  strategy:
    matrix:
      linux:
        platform: linux
      windows:
        platform: windows
      mac:
        platform: mac

  pool:
    ${{ if eq(variables.platform, 'linux') }}:
      name: AzurePipelines-EO
      demands:
      - ImageOverride -equals AzurePipelinesUbuntu20.04compliantGPT
      os: Linux
    ${{ if eq(variables.platform, 'windows') }}:
      name: VSEngSS-MicroBuild2022-1ES
    ${{ if eq(variables.platform, 'mac') }}:
      name: Azure Pipelines
      vmImage: macOS-12
      os: macOS

方案说明

  1. 矩阵中仅存储标量类型的platform变量,标识当前运行的平台
  2. 在pool节点使用Azure Pipelines的编译期条件表达式${{ if }},根据platform变量的值渲染对应平台的Pool配置
  3. 条件表达式在YAML编译阶段执行,每个矩阵维度会生成独立且符合要求的Pool结构,完全适配不同平台的配置差异

内容的提问来源于stack exchange,提问作者Andrew Arnott

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:07:12