Reputation: 2019
I'm trying to pass a variable value from one job to another in a Azure Devops pipeline.
I've tried following the documentation in Microsoft docs diligently.
For example here:
However, it's not working as expected.
Can anyone point out where the problem is?
Here's the pipeline
https://github.com/ossentoo/azure-devops-pipelines
jobs:
- job: A
steps:
- script: echo "##vso[task.setvariable variable=applicationId;isOutput=true]629ae9cb-95e0-46b7-8a88-a4034b68323e"
name: mytask
- job: B
variables:
newValue: $[dependencies.A.outputs['mytask.applicationId']]
dependsOn: A
steps:
- powershell: |
Write-Host "This value is: ${{variables.newValue}}"
displayName: 'Output the value'
the output from this pipeline in the Powershell task is:
This value is: $[dependencies.A.outputs['mytask.applicationId']]
You can see the output here:
It is almost as if $[]
is not being recognized by Azure DevOps as a variable value.
thanks
Upvotes: 2
Views: 2526
Reputation: 30313
In your last powershell step invoke newValue with $()
syntax instead of ${{}}
- powershell: |
Write-Host "This value is: $(newValue)"
I think the reason ${{}}
not working might be that ${{}}
is for parse time and executed before $[[]]
is executed.
Upvotes: 4