Passing Values Between Tasks in Azure DevOps Pipeline


Azure DevOps pipeline consists of various Tasks that run in a Virtual Machine known as an Agent. Each Task gets allocated resources during execution, which are then de-allocated once the Task finishes, creating isolated execution scopes.

When communication between Tasks is necessary, we need to explore methods to pass values between them.


Consider a scenario where you need to create a Storage Account and generate a SAS token in one Task, then use that token in subsequent Tasks to access the Storage Account.

This situation may involve Tasks within the same Job, different Jobs within a Stage, or across different Stages.


By utilizing the logging command task.setvariable, we can pass variables across Tasks within the Azure DevOps pipeline. This enables sharing values between Tasks within the same Job, across different Jobs in a Stage, or even across Stages.

About task.setvariable

The task.setvariable logging command allows for creating variables that can be shared across Tasks within the pipeline, with options to control their visibility and security.

SetVariable Properties

Below are the properties associated with the task.setvariables command:

Property Description
Variable Specifies the variable name using $(var name) syntax
Isoutput Enables using the variable outside the current Job or across Stages
Issecret Makes the variable a Secret
Read-only Specifies a read-only variable

For further understanding, let’s set up a pipeline structure with multiple Stages, Jobs, and Tasks.

Share variables between Tasks within a Job

Demonstrate creating and accessing a new variable within the same Job.

Share variables between Tasks across the Jobs (of the same Stage)

Illustrate passing variables from one Task to another across different Jobs within the same Stage.

Share variables between Tasks across the Stages

Showcase sharing variables between Tasks located in different Stages of the pipeline which may require dependencies between the Stages.


In this article, we have explored utilizing Logging commands to facilitate variable sharing among Tasks located:

  • Within the same Job
  • Across Jobs within a Stage
  • Across Jobs in different Stages

Learn more about our services and solutions at Skrots. Explore the range of services we offer at Skrots Services. Thank you for visiting our site!

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button