In Azure Pipelines you can set pipeline variables at queue time. You can use such a variable the same way as variables defined by the pipeline itself.
Example:
# pipeline.yml
steps:
- checkout: none
- template: steps/some.yml
parameters:
name: $(queueTimeVar)
# steps/some.yml
parameters:
name: 'World'
steps:
- bash: |
echo "Hello ${{ parameters.name }}!"
But if the variable isn't set explicitly, the pipeline evaluates this expresstion to the string itself. The step template would be called with name: '$(queueTimeVar)'
and print Hello $(queueTimeVar)!
.
How could I set a default value if the variable wasn't set?
I tried adding the default value as variable but it didn't work as expected.
variables:
queueTimeVar: MyDefault
Afterwards the queue time variable had no effect. The variable was always the YAML value.
As workaround I had to add the default handling to every task which uses the value.
# bash task
value="MyDefault"
if [ -n "$QUEUETIMEVAR" ]; then
value="$QUEUETIMEVAR"
fi
variable
within the YAML and in particlar cases (e.g. test/error analysis) I can override that value with a queue time variable. But I didn't work. – sschmeck