0

In Azure, I have a release pipeline with two stages. The first stage stores a value to a pipeline variable. I need to access that variables value in the 2nd stage's tasks. Currently the value retrieved in the second stage is empty. Is it however not empty when accessed within the same stage (multiple tasks in the same stage).

I have checked out Microsoft's documentation and it seems to only show YAML.

oguz ismail
  • 1
  • 16
  • 47
  • 69
pnizzle
  • 6,243
  • 4
  • 52
  • 81

1 Answers1

2

How to access stageDependencies variables in multiple stages in Azure Release pipeline using bash

Yes, the Stage to stage dependencies only used for the YAML pipeline.

For the Classic pipeline, we need to pass them manually so that we can use them in the next stage.

We could use the REST API to update the variable in the Variables tab.

Steps:

  • Define a variable in the release definition Variable.
  • Use REST API (Definitions - Update) to update the value of the release definition variable in the stage 1.
  • Use the updated value of the release definition variable in the second stage.

The details info about using REST API to update the value of the release definition variable, you can follow the below ticket:

How to modify Azure DevOps release definition variable from a release task?

or you could use the Azure CLI to update the variable:

az pipelines variable update --name
                             [--allow-override {false, true}]
                             [--detect {false, true}]
                             [--new-name]
                             [--org]
                             [--pipeline-id]
                             [--pipeline-name]
                             [--project]
                             [--prompt-value {false, true}]
                             [--secret {false, true}]
                             [--subscription]
                             [--value]
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I ended up having the stages tasks all in one stage so the variables can be shared. Will try this approach when I get an opportunity. Cheers – pnizzle Aug 12 '21 at 02:50
  • Not yet sadly. I will be sure to let you know once I have feedback. – pnizzle Aug 22 '21 at 23:28