I have a nested Azure DevOps YAML pipeline:
---
name: Some Release Pipeline
trigger: none
variables:
- group: "DEV VARIABLE GROUP" # This is the environment variable library
stages:
- stage: Stage1
displayName: "Stage 1"
dependsOn: []
jobs:
- template: /pipelines/pipeline_templates/sometemplate.yml
What I would like to do is reuse this release pipeline for any environment. Ideally I would set a pipeline variable "group-name" and then assign it to the group. Something like this:
---
name: Some Release Pipeline
trigger: none
variables:
- group: "$(group-name)" # This is the environment variable library
stages:
- stage: Stage1
displayName: "Stage 1"
dependsOn: []
jobs:
- template: /pipelines/pipeline_templates/sometemplate.yml
However, this doesn't seem to work. Desperately, I've tried a variety of approaches:
- Using
${{ group-name }}
- I've tried to pass the group-name as a parameter using:
jobs:
- template: /pipelines/pipeline_templates/sometemplate.yml
parameters:
variablegroup: $(group-name)
and then setting it in the sometemplate.yml in the job. eg:
jobs:
- job: Job1
variables:
- group: ${{ parameters.variablegroup }}
However, this didn't work neither.
- I've tried using insertion (
{{ insert }}
) as suggested here. However, either I don't know how to use insertion properly, or that doesn't work either as I was always encountering some form of validation errors.
According to this, and this, and this, and this it doesn't seem possible.
I am wondering if anyone has found a solution to this yet (other then doing a really messy workaround of calling the DevOps REST API)?