Marko
Marko

Reputation: 1359

Conditionally use a variable group in azure pipelines

I know that it is possible to conditionally set a variable in azure pipelines yml. See https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#conditional-insertion

Is it also somehow possible to conditionally use a variable group?

Let's say if a pipeline run variable is set or has a certain value then the pipeline shall use a variable group. If not then the group shall not be used.

Thank you

Upvotes: 3

Views: 3281

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40603

Is it possible like here for instance:

trigger: none
pr: none

variables:
  isProd: true

stages:
- stage: Test
  displayName: Build and restore
  variables:
  - ${{ if eq(variables['isProd'], 'false') }}:
    - group: QA
  - ${{ if eq(variables['isProd'], 'true') }}:
    - group: PROD
  jobs:
  - job: A
    steps:
    - bash: echo $(name)

Upvotes: 6

Related Questions