I’m traying to share a variable between a deploy job and a normal job in azure pipelines, when i try to print the variable im getting echo is off error.
Hey guys i´m having the next problem with azure pipelines
stages:
- stage: Stage
jobs:
- deployment: Staging
displayName: Stage the WebApp
environment:
name: 'Windows10'
resourceName: Lxxxxxx
resourceType: virtualMachine
strategy:
runOnce:
deploy:
steps:
- powershell: echo "##vso[task.setvariable variable=myStageOutputVar;isOutput=true]variable"
name: printvar
- stage: Swap
dependsOn: Stage
variables:
myVarfromStage: $[ stageDependencies.Stage.Staging.outputs['Windows10.printvar.myStageOutputVar'] ]
jobs:
- deployment: Production
displayName: Swap to production
environment:
name: 'Windows10'
resourceName: Lxxxxxx
resourceType: virtualMachine
strategy:
runOnce:
deploy:
steps:
- script: echo $(myVarfromStage)
and im getting the next log when running the pipeline
Starting: CmdLine
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.231.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents: shell
echo
========================== Starting Command Output ===========================
"C:WINDOWSsystem32cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cmd""
ECHO is off.
Finishing: CmdLine
and if i want to do this between a deployment and a job how can i do it.
Appreciate.
2
Answers
Use
job.task.variable
format instead ofenvironment.task.variable
for the outputs section inSwap
stage.(Examples: Support for output variables)Result:
Docs reference.