gpt4 book ai didi

azure-devops - Azure Devops YML 条件阶段模板

转载 作者:行者123 更新时间:2023-12-05 04:51:41 25 4
gpt4 key购买 nike

Visual Studio 2019 16.8.5

我想为阶段使用模板。有些阶段,我想根据条件。但是,当我在 YML 文件中尝试这样做时,它会产生错误。下面是 azure-pipelines.yml 文件中的两次尝试:

stages:
- template: 'build.yml'

- template: 'deploy.yml'

- template: 'test.yml'

- ${{ if eq('true', 'true') }}:
- template: 'optional.yml'

结果:

Severity    Code    Description Project File    Line    Suppression State
Error Property ${{ if eq('true', 'true') }} is not allowed. azure-pipelines.yml 8

还有这个:

stages:
- template: 'build.yml'

- template: 'deploy.yml'

- template: 'test.yml'

- template: 'optional.yml'
condition: eq('true', 'true')

结果:

Severity    Code    Description Project File    Line    Suppression State
Error Property template is not allowed. azure-pipelines.yml 8

上述语法有什么问题,需要什么才能无误地实现要求?

最佳答案

Error Property ${{ if eq('true', 'true') }} is not allowed. azure-pipelines.yml 8

根据错误消息,此问题存在于 Visual Studio 中。

这是一个关于 If expression in Azure Devops 的文档.

您可以直接在 Azure Pipeline 中创建 yaml 示例。

enter image description here

它可以在 Azure Devops Pipeline 中正常运行。

对于格式condition: eq('true', 'true'),模板字段不支持添加条件参数,所以不能使用。

更新:

与 Mark 讨论,"if"语法在 Yaml 文件中确实有效,但由于新版本 Visual Studio 的限制,它在 Visual Studio 中显示为错误。

关于azure-devops - Azure Devops YML 条件阶段模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66806516/

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