1

I have a pipeline in Azure DevOps that essentially look like this

stage: BuildStage
   job: SetUp
   job: Compile
stage: DeployStage
   job: Deploy

In the SetUp job I define an output variable, which I can define in the Compile job using e.g.

variables:
   MyVariableFromSetUp: $[ dependencies.SetUp.outputs['MyVariable'] ]

The question is, how can I do the same in the Deploy job? I don't want to run the SetUp stage twice as it is time consuming to calculate the value of MyVariable hence I must cache it.

The DeployStage has a dependsOn to BuildStage, but it appears I cannot use the dependencies as I expected. The documentation fails to mention the multi-stage case when dealing with variables.

Krumelur
  • 31,081
  • 7
  • 77
  • 119

1 Answers1

1

Hey there is no direct way to do this at present based on what I have found, you would be following one of the following 3 methods

  1. Passing it as artifact value using this method https://medium.com/microsoftazure/how-to-pass-variables-in-azure-pipelines-yaml-tasks-5c81c5d31763

  2. Passing it via a API Endpoint using VSTeam powershell module https://www.donovanbrown.com/post/Passing-variables-from-stage-to-stage-in-Azure-DevOps-release, similar method can also be found here https://stefanstranger.github.io/2019/06/26/PassingVariablesfromStagetoStage/

Sl-NZ
  • 64
  • 2
  • 13
  • 1
    Thanks, this is what I also found. I just wanted to confirm that I didn't miss anything. I guess artifacts will have to do until MS decides to add this (feels like an omission). – Krumelur Apr 09 '20 at 08:27