I am trying to transfer a variable to a template. I have tried: ${{ variables.portalPath }} and $(portalPath)
But no values are transferred. If I dont use a variable but just a string it works:
pipeline:
trigger:
- none
variables:
- name: portalPath value:"sdfsdf"
extends:
template: azure-pipelines-build-react-portal-template.yml
parameters:
portalPath: "I WOULD LIKE TO REPLACE THIS WITH VARIABLE"
Template:
parameters:
- name: portalPath
type: string
steps:
- script: echo ${{ parameters.portalPath }}
Run-time variables are not yet available at the time the value pass to
portalPath
is interpreted. The template parameter would then receive a run-time variable $(portalPath).Instead ofpassing the variable in run-time syntax but use the expression syntax
${{ variables.environment }}
:Template.yml
azure-pipelines.yml
If this is still not work. A workaround here is introducing simply a new variable in your in the beginning of your job (with powershell or bash):
- powershell: Write-Host "##vso[task.setvariable variable=PortalPath ]${{ parameters.portalPath }}"
From that point on you can use ${PortalPath }in your further steps.
You could also take a look at below similar question:
Azure Pipelines: Passing a variable as a parameter to a template
Passing variable as a parameter for conditions to template