I have a Variable group called "CI environments" with those variables:
I have a yaml pipeline with a variable called CIDatabase in a branch called Branch1
Can I set the value of CIDatabse like this?
echo "##vso[task.setvariable variable=CIDatabase ]variables.$(TR_CI_${{variables['Build.SourceBranchName']}})"
Build.SourceBranchName
is a predefined variable available in templates, so you don't need to set output variables.
Try using template expression syntax ${{ ... }}
instead:
variables:
- group: 'CI environments'
- name: CIDatabase
# e.g. if source branch name is 'dev' then variable value will be '$(CI_dev)'
value: "$(CI_${{ variables['Build.SourceBranchName'] }})"
steps:
- script: |
echo "Database: $(CIDatabase)"