Been banging my head on this for a few days now – i am sure its something obvious…. but i am missing it…
What i want to do is to pass a variable called publish defined in the pipeline definition UI into a template called echo.yml from the main pipeline.yml then in the template use the value of the variable as a condition on a task running or not.
So far no success.
Is this actually possible ?
Simplified example below, the real use case is to control whether or not a publish task executes.
echo.yml
parameters:
- name: 'desc'
type: string
default: none
- name: 'publish'
type: string
default: 'false'
steps:
- task: Bash@3
condition: ${{ parameters.publish }}
inputs:
targetType: 'inline'
script: |
echo desc is ${{ parameters.desc }}
echo publish is ${{ parameters.publish }}
pipeline.yml
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
# Write your commands here
echo SBN IS $(Build.SourceBranchName)
echo SB IS $(Build.SourceBranch)
- template: echo.yml
parameters:
desc: 'my description'
publish: ${{ variables.publish }}
JamesSan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.