In my Azure DevOps YAML pipeline, the deployment of a website has been coded in a reusable template. This template will execute a step depending on the value of an input paramter:
# Template 'deployTemplate.yml'
parameters:
- name: preDeployApprovalRequired
type: string
jobs:
- job: PrintVariables
steps:
- ${{if eq(parameters.preDeployApprovalRequired, 'true')}}:
- powershell: |
Write-Host "Pre deploy required: '${{parameters.preDeployApprovalRequired}}'"
- ${{else}}:
- powershell: |
Write-Host "Pre deploy NOT required: '${{parameters.preDeployApprovalRequired}}'"
and this template is called as follows
# Pipeline
# Beginning of pipeline is omitted, works as intended
- stage: Development
variables:
- group: Development #Reference to Library
jobs:
- template: deployTemplate.yml
parameters:
preDeployApprovalRequired: $(PreDeployApprovalRequired)
Here $(PreDeployApprovalRequired)
comes from the Library named ‘Development’, I’ve verified that the value is true
, and as can be deduced from the code above, the value will be printed in the Powershell task. When running the pipeline, I see in the output: Pre deploy NOT required: 'true'
. Why?? To make things even more puzzling, if I modify the last line in the pipeline to preDeployApprovalRequired: 'true'
or preDeployApprovalRequired: true
(no quotation marks around the word true
), i.e. the value is hard-coded in the pipeline and does not come from the Library, the output is Pre deploy required: 'true'
, as expected.
Any ideas on how I can conditionally execute a task based on the value in a Library?