0
votes

In the UI (classic) Release pipelines, there are build-in variables like $(Release.EnvironmentName), which changes depending on which stage you are at.

Is there an equivalent when using a YAML pipeline?

Also in the classis mode variable groups are automatically scoped to the stage if there are linked, is this also possible in YAML somehow?

1

1 Answers

0
votes

The answer is yes. The usage of the predefined variable in Yaml pipeline is the same with classic pipeline. $(Release.EnvironmentName) is for classic release pipeline. You can refer to variables $(System.StageName) or $(Environment.Name) in the yaml pipeline.

Click the links to find more predefined build variables. Check here to learn more about variables in yaml pipeline.

For variable groups scoped to stage in classic release pipeline

It is possible in Yaml pipeline. In yaml you can scope your variable groups in job or stage by define variables under job or stage in yaml. For below example.

1,Variables scoped to stage Build:

stages:
- stage: Build
  variables:
      - group: SourceMessage 
  jobs:
  - job: A            
- stage: release     
  jobs:
  - job: B

2, Variables scoped to all stages:

stages:
variables:
  - group: SourceMessage 
- stage: Build 
  jobs:
  - job: A            
- stage: release     
  jobs:
  - job: B

3, Variables scoped to job A:

stages:
- stage: Build 
  jobs:
  - job: A  
    variables:
    - group: SourceMessage 
- stage: release     
  jobs:
  - job: B