I have a simple yaml pipeline that calls a template analyze-and-deploy.yml.
I concatenate ${{ parameters.Environment }}_USERNAME to create a username parameter dynamically and pass it when calling template analyze-and-deploy.yml. I want to then retrieve the value of dynamically created USERNAME from a "library" in my Azure DevOps project and run a script as a step in analyze-and-deploy.yml.
I can pass the value as parameter e.g. if environment is "Dev", then I can see DEV_USERNAME is passed to analyze-and-deploy.yml, but how do I expand this dynamic variable with actual value from library named "VG1"?
In VG1, I have variables DEV_USERNAME, QA_USERNAME and I want it to get value depending on the environment.
resources:
repositories:
- repository: templates
type: git
name: sharedpipelines
ref: refs/heads/main
parameters:
- name: sourceDirectory
type: string
default: 'core'
- name: Environment
type: string
values:
- DEV
- QA
default: DEV
variables:
- group: "VG1"
stages:
- ${{ if ne(parameters.workstream, '') }}:
- template: templates/analyze-and-deploy.yml@templates
my_username: "${{ parameters.FromEnvironment }}_USERNAME"
