我正在尝试在天蓝色管道中的部署作业和正常作业之间共享一个变量,当我尝试打印变量时,我收到 echo is off 错误。
大家好,我遇到了天蓝色管道的下一个问题
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)
我在运行管道时获取下一个日志
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:\WINDOWS\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\xxxxx\xxxxx\xxxxx\xxxxxxx\xxxxxxxxxxxxx.cmd""
ECHO is off.
Finishing: CmdLine
如果我想在部署和工作之间执行此操作,我该怎么做。
欣赏。
在
job.task.variable
阶段的输出部分使用environment.task.variable
格式而不是Swap
。(示例:支持输出变量)
- stage: Swap
dependsOn: Stage
variables:
myVarfromStage: $[ stageDependencies.Stage.Staging.outputs['Staging.printvar.myStageOutputVar'] ]
结果: