top of page
Writer's pictureSumit Raj

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

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
  1. dependencies

  2. 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>



GitHub Link



Demo





Comments


bottom of page