azure - 如何从 azure 管道中选择特定的构建代理来运行您的构建?
问题描述
因此,我试图想出一种方法来允许在构建管道中轻松选择给定代理,仅用于调试目的。到目前为止,我有以下片段。两者都可以在没有 if 片段的情况下工作,但是我试图根据设置的参数或设置的变量来执行其中一个或另一个,这样如果它处于调试模式,它将选择和代理,如果不是,那么它只会使用池来选择一个代理来运行构建。到目前为止,虽然没有运气。
variables:
debugMode: 'false'
parameters:
- name: poolOption
type: string
default: 'ZupaDeploymentPool'
- name: debugMode
type: string
default: 'true'
- name: debugMachine
type: string
default: 'ZUPBUILD03'
trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- README.md
${{ if ne($(debugMode), 'false') }}:
pool: ${{ parameters.poolOption }}
${{ if ne($(debugMode), 'true') }}:
pool:
name: ${{ parameters.poolOption }}
demands:
- Agent.Name -equals ${{ parameters.debugMachine }}
解决方案
因此,在与上面的 kevin-lu-msft 进行快速聊天后,我将使用此解决方案来处理在池中选择特定代理。
parameters:
- name: debugMachine
displayName: 'Run on selected agent:'
type: string
default: 'Auto Select From Pool'
values:
- 'Auto Select From Pool'
- 'MACHINE01'
- 'MACHINE02'
- 'MACHINE03'
- 'MACHINE04'
- 'MACHINE05'
jobs:
-job: build
# -----------------------------------------------------------------------------------------------
# This is the pool selection section if a specific debug machine is passed in via the params
# It will select that specific one to run the build on. unfortunately azure doesnt let you pass
# vars or params to the process string in the demands which would have made this alot cleaner.
pool:
name: 'YOUAGENTSPOOLNAME'
${{ if ne(parameters.debugMachine, 'Auto Select From Pool') }}:
${{ if eq(parameters.debugMachine, 'MACHINE01') }}:
demands:
- Agent.Name -equals MACHINE01
${{ if eq(parameters.debugMachine, 'MACHINE02') }}:
demands:
- Agent.Name -equals MACHINE02
${{ if eq(parameters.debugMachine, 'MACHINE03') }}:
demands:
- Agent.Name -equals MACHINE03
${{ if eq(parameters.debugMachine, 'MACHINE04') }}:
demands:
- Agent.Name -equals MACHINE04
${{ if eq(parameters.debugMachine, 'MACHINE05') }}:
demands:
- Agent.Name -equals MACHINE05
steps:
- script: "echo finally it works"
推荐阅读
- google-apps-script - onEdit 函数,其中特定列中的操作设置下一列中相应行的值
- dns - XN开头的153个顶级域名有哪些?
- react-native - KeyboardAvoidingView + React Navigation + 安全区域视图 = 不工作
- amazon-s3 - Terraform:遵守限制错误
- javascript - 无法在 Anchor 内设置 Grommet 图标
- c++ - 如何处理这个循环?
- firebase - 带有firebase的flutter应用程序在热重载时崩溃
- templates - Consul-Termplate - 将变量插入“带秘密”证书调用的语法是什么
- arrays - Powershell:读取主机以选择数组索引
- html - 在 VS Code 中保存时关闭自动关闭的 HTML 标签?