gpt4 book ai didi

ios - 如何从 Azure DevOPS 中的池在特定代理上运行管道

转载 作者:行者123 更新时间:2023-12-01 19:30:16 25 4
gpt4 key购买 nike

我们将 Azure DevOps 用于 iOS 应用程序的 CI/CD。我们提供了带有 VM 的 mac 机器,Azure DevOps 代理安装在这些 VM 上。

有时我们的管道会因代理 VM 不稳定而失败。如何在管道中提供选项以在池中的特定代理上运行作业?这在 Jenkins 和 TeamCity 中都很容易实现。然而,在这里我们使用 YAML 定义管道,这似乎更棘手。

带有机器列表的参数以及管道中的能力条件和代理中定义的能力是否可行?

最佳答案

but keep in mind that: 1. I'd love to choose it while clicking "Run job", 2. List of available agents should be possible as a dropdown menu 3. By default it should use a random agent from pool

为了在 YAML 文件中实现这一点,我们可以定义两个 Runtime parameters ,其中一个参数用于从下拉列表中选择指定代理,一个用于决定是使用特定代理还是默认使用随机代理。

换句话说,我们需要使用一个参数来选择需求,并使用另一个参数来禁用/启用先前的需求。如果我们禁用之前的需求,Azure devops 将默认使用随机代理。

我设置了以下示例 YAML 文件:

parameters:
- name: IfNeedDemands
type: boolean
default: False


- name: AgentSelect
displayName: Agent Select
type: string
values:
- VsAgent1
- VsAgent2
- VsAgent3
- VsAgent4

trigger: none

jobs:
- job: build

displayName: build
pool:
name: MyPrivateAgent
${{ if eq(parameters.IfNeedDemands, true) }}:
demands: Agent.Name -equals ${{ parameters.AgentSelect }}

steps:
- script: echo The value is ${{ parameters.AgentSelect }}

在上面的示例中,参数 IfNeedDemands 语法为 ${{ if eq(parameters.IfNeedDemands, true) }}: 用于确定是否启用 要求

然后参数AgentSelect用于选择私有(private)代理。

enter image description here

我测试了它是否符合我的预期,你可以检查它是否满足你的需求。

关于ios - 如何从 Azure DevOPS 中的池在特定代理上运行管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63298778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com