Azure Devops YML 条件阶段模板
Azure Devops YML Conditional Stage Template
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 示例。
它可以在 Azure Devops Pipeline 中正常工作。
格式condition: eq('true', 'true')
,模板字段不支持添加条件参数,无法使用。
更新:
与 Mark 讨论,"if" 语法在 Yaml 文件中确实有效,但由于新版本 Visual Studio.[=14= 的限制,它在 Visual Studio 中显示为错误]
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 示例。
它可以在 Azure Devops Pipeline 中正常工作。
格式condition: eq('true', 'true')
,模板字段不支持添加条件参数,无法使用。
更新:
与 Mark 讨论,"if" 语法在 Yaml 文件中确实有效,但由于新版本 Visual Studio.[=14= 的限制,它在 Visual Studio 中显示为错误]