I have a very basic YAML azure pipeline
jobs:
- job: Foo
steps:
- bash: |
echo "Create variable xyz"
echo "##vso[task.setvariable variable=xyz;]yes"
displayName: 'Determine slot name'
- bash: |
echo "Var is: $(xyz)"
displayName: 'Show variable'
- job: Bar
dependsOn: Foo
steps:
- bash: |
echo "Hello world $(Foo.xyz)"
displayName: 'Show variable'
In the first JOB, named Foo
, the variable xyz
is set to yes
. Which works, because I can display it in the seconds step with the line
echo "Var is: $(xyz)"
However, I would like to use that variable in the next job (named Bar
). But whatever I do it does not exist. I tried things like
echo "Hello world $(xyz)"
or
echo "Hello world $(Foo.xyz)"
But both give the following error when I run the pipeline
line 1: Foo.xyz: command not found
How can I share that variable between jobs? and sharing between stages would be nice too!!