我们目前必须一次运行QA,IAT和VNEXTIAT的管道,因为环境变量似乎是从其他环境中污染的。
为什么这是发生的?
为什么自己运行时可以吗?
在YAML管道(和通讯模板)中,您可以在各种范围内设置一个变量:
根级(管道):可用于管道中的所有作业。 级级别:仅适用于特定阶段。
工作级:仅适用于特定工作。 您应该尽可能多地降低与环境相关变量的范围 - 理想情况下将它们设置为
job级别,但在某些情况下,在阶段级别上也可能还可以。这应该防止其他环境中变量的“ concontamination”(使用您的表达式)。
示例 - 在作业级别引用parameters:
# other parameters here
- name: environment
type: string
displayName: 'Environment'
jobs:
- job: deploy_${{ parameters.environment }}
displayName: 'Deploy to ${{ parameters.environment }}'
variables:
# Consumers of this job are expected to provide a variables template
# using the following folder structure:
# /pipelines/variables/{environment}-variables.yaml
- template: /pipelines/variables/${{ parameters.environment }}-variables.yaml@self
steps:
# ...