Greetings!!!
I'm trying to pass variable values from the below yml to json files in azure devops ci cd pipeline. Using the below code I have been trying to pass the variable values based on environment to the json file but the actual ResourceGroup value is not showing up after deployment. Still shows up as
"$(resourceGroup)"
Not sure how to address this. Please guide me in the right direction.
Here I'm trying to test out passing variable values to the .json files which are in the trigger folder. But, later extend it out to other artifacts as well.

json:
{
"name": "myTestTrigger",
"properties": {
"description": "Test",
"pipelines": [
{
"pipelineReference": {
"referenceName": "myPipeline",
"type": "PipelineReference"
},
"parameters": {
"resourceGroup": "$(resourceGroup)"
}
}
]
}
}
yml:
parameters:
- name: env
displayName: Deploy environment
type: string
default: 'development'
values:
- development
- test
- preproduction
variables:
- name: resourceGroup
${{ if eq( parameters['env'], 'development') }}:
value: "developmentResourceGroup"
${{ elseif eq( parameters['env'], 'test' ) }}:
value: "testResourceGroup"
${{ else }}:
value: "preproductionResourceGroup"
stages:
- ${{ if eq( parameters['env'], 'development') }}:
- stage: stage1
jobs:
- job: stage1job
steps:
- task: Bash@3
displayName: stageselected
inputs:
targetType: inline
script: |
echo "The stage selected was stage1 as env: ${{parameters.env}} was selected and RG ${{variables.resourceGroup}"
- ${{ elseif eq( parameters['env'], 'test') }}:
- stage: stage2
jobs:
- job: stage2job
steps:
- task: Bash@3
displayName: stageselected
inputs:
targetType: inline
script: |
echo "The stage selected was stage2 as env: ${{parameters.env}} was selected and RG ${{variables.resourceGroup}}"
- ${{ else }}:
- stage: stage3
jobs:
- job: stage3job
steps:
- task: Bash@3
displayName: stageselected
inputs:
targetType: inline
script: |
echo "The stage selected was stage3 as env: ${{parameters.env}} was selected and RG ${{variables.resourceGroup}"
variables:
- name: resourceGroup
value: ${{ if ("$(env)" -eq "development") }}developmentResourceGroup
${{ if ("$(env)" -eq "test") }}testResourceGroup
${{ if ("$(env)" -eq "pre-production") }}preproductionResourceGroup
steps:
- script: |
echo '{ "myResourceGroup": "$(resourceGroup)" }' > $(Build.ArtifactStagingDirectory)/myTestTrigger.json