Skip to content
Latchkey

How to Set Output Variables Between Jobs in Azure Pipelines

A job exposes a value to downstream jobs by setting an output variable, which dependents read via the dependencies context.

Emit a value with the task.setvariable logging command and isOutput=true. A dependent job that dependsOn the producer reads it from dependencies.<job>.outputs.

Produce and consume an output

The producer names a step (setVer); the consumer maps the output into its own variable.

azure-pipelines.yml
jobs:
  - job: Producer
    steps:
      - script: echo "##vso[task.setvariable variable=version;isOutput=true]1.4.2"
        name: setVer
  - job: Consumer
    dependsOn: Producer
    variables:
      ver: $[ dependencies.Producer.outputs['setVer.version'] ]
    steps:
      - script: echo "Deploying $(ver)"

Gotchas

  • The producing step MUST have a name: - the output is referenced as <stepName>.<varName>.
  • Mapping uses runtime expression syntax $[ ... ], not macro $( ).
  • For cross-stage outputs, use stageDependencies instead of dependencies.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →