Reputation: 11931
I am trying to pass a Pipeline variable (enable_datasync_job
) that I have defined using the UI:
to a template that is used within my main pipeline azure-pipelines.yml
:
name: MyRepo.Deployment.$(date:yy)$(DayOfYear)$(rev:.r)
...
jobs:
- job:
steps:
...
- template: azure-pipelines.yml@Common-YAML
parameters:
...
enable_datasync_job: $(enable_datasync_job)
The Common-YAML
template defines that variable as boolean
:
parameters:
...
- name: enable_datasync_job
type: boolean
default: false
When I try to run my main pipeline, it currently breaks as it completes that I am not passing a boolean value to my template
I know that all pipeline variables as of type string. How do I convert that string to a boolean so that my template accepts it?
Upvotes: 1
Views: 1041
Reputation: 1646
If you define the parameter that is in the azure-pipelines.yml
also as boolean
you will get a checkbox (boolean) instead of inputbox (string):
You should be able to pass this along the Common-YAML
.
The azure-pipelines.yml
:
trigger:
- main
pool:
vmImage: ubuntu-latest
parameters:
- name: enable_datasync_job
type: boolean
default: false
extends:
template: boolean.yml
parameters:
enable_datasync_job: ${{ parameters.enable_datasync_job }}
The azure-pipelines.yml
, without extends
:
trigger:
- main
pool:
vmImage: ubuntu-latest
parameters:
- name: enable_datasync_job
type: boolean
default: false
steps:
- template: boolean.yml
parameters:
enable_datasync_job: ${{ parameters.enable_datasync_job }}
The boolean.yml
(Common-YAML
):
parameters:
- name: enable_datasync_job
type: boolean
default: false
steps:
- script: |
echo the value is ${{ parameters.enable_datasync_job }}
Upvotes: 3