top of page

LetsDevOps: How to share variables across stages, jobs and steps in Azure DevOps YAML pipeline

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

ree


Within Same Stage Different Jobs


ree


Within Different Stage

ree



Dependencies:

We can use the dependencies keyword for referring the previous stage and jobs


Keyword
  1. dependencies

  2. stagedependencies


ree

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>


ree

GitHub Link



Demo





 
 
 

Comments


bottom of page