LetsDevOps: How to share variables across stages, jobs and steps in Azure DevOps YAML pipeline
- Sumit Raj
- Oct 1, 2023
- 1 min read
Updated: May 18, 2024
Introduction
In this blog we will learn how to share the runtime variables across multiple stages, jobs.
In ADO this is referenced as the dependencies and we can use for below use case.
Prerequisite
You should know the basic for ADO yaml. If you are new to YAML here is the beginner's guide.
Use Case:
Assume we have to define some variables that can defined at runtime which is further required to pass -->
Within Same Job Different Steps

Within Same Stage Different Jobs

Within Different Stage

Dependencies:
We can use the dependencies keyword for referring the previous stage and jobs
Keyword
dependencies
stagedependencies

Syntax
Same Stage
dependencies.<Job-name>.outputs['<step-name>.<variable-name>']
Different Stage
stageDependencies.<Stage-name>.<Job-name>.outputs['<step-name>.<variable-name>']
Same Job
<step-name>.<variable-name>
