1

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:

https://dev.azure.com/mercle/Concepts/_build/results?buildId=6151&view=logs&j=b79b690b-82d1-5750-8a0a-452d70195841&t=744de4c6-b805-5a86-cd25-7a780a8b3a55&l=12

It is almost as if $[] is not being recognized by Azure DevOps as a variable value.

thanks

akokskis
  • 1,486
  • 15
  • 32
ossentoo
  • 1,675
  • 2
  • 20
  • 44

1 Answers1

4

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.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • hey, can you add a reference to documentation about this parse time? It would be helpful to get more info about the timings what happens when. thanks. – J-ho May 18 '21 at 14:05