1

I am using classic Azure DevOps release pipeline and there are 3 different stages.

In first stage I am running a PowerShell script and that sets up a dynamic variable as Write-Host "##vso[task.setvariable variable=svc_password;issecret=true;isOutput=true]$token"

In second stage I am running a python script and need to access above variable value, is there a way to do that?

Naveen Kumar
  • 1,266
  • 1
  • 21
  • 50
  • Is this what you need? https://stackoverflow.com/questions/57485621/share-variables-across-stages-in-azure-devops-pipelines – Aman B Mar 10 '22 at 07:51
  • @AmanB Yes but I am using classic pipeline not yaml so how to pass this value as argument in python script next stage . – Naveen Kumar Mar 10 '22 at 08:01
  • Answer is already provided on https://stackoverflow.com/questions/62128394/pass-azure-devops-release-pipelineclassic-editor-output-variable-to-multiple-j . You must use YAML to consume output variables in different jobs. – GeralexGR Mar 10 '22 at 08:06

1 Answers1

1

There is the documentation: Set an output variable in a future job.

Example:

jobs:
- job: A
  steps:
  - bash: |
     echo "##vso[task.setvariable variable=myOutputVar;isoutput=true;issecret=true]this is from job A"
    name: passOutput
- job: B
  dependsOn: A
  variables:
    myVarFromJobA: $[ dependencies.A.outputs['passOutput.myOutputVar'] ]  
  steps:
  - bash: |
     echo $(myVarFromJobA)
Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31