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
stageDependenciesinstead ofdependencies.
Related guides
How to Define Stages and Jobs in Azure PipelinesStructure an Azure Pipeline with stages, jobs, and steps. Learn the hierarchy, dependsOn ordering, and when e…
How to Publish and Download Pipeline Artifacts in Azure PipelinesPass files between jobs and stages in Azure Pipelines with PublishPipelineArtifact and DownloadPipelineArtifa…