1
votes

Using the Azure Devops gui, it is very easy to scope variable groups to pipeline stages. I need to replicate this functionality in a yaml build/release pipeline but I cannot find a way to do it. Anyone found a way to do this yet?

1

1 Answers

4
votes

Scope variable groups to pipeline stages functionality in a yaml build/release pipeline

With YAML, the way to achieve that is just specify the Variable group at the stage level to let it available only to this specific stage.

For example, I have a variable group names 1122. And 2 stages: one and two. Now, I want this variable group only available for stage one, which means the stage two should not access its content.

See below simple sample:

stages:
- stage: one
  displayName: one
  variables:
  - group: 1122

  jobs:
  - job: A
    steps:
      - bash: echo $(a)


- stage: two
  displayName: two

  jobs:
  - job: A1
    steps:
      - bash: echo $(a)

enter image description here