我正在尝试使新的阶段变量起作用。这是我的精简示例:-
stages:
- stage: firstStage
jobs:
- job: varSetJob
pool:
vmImage: 'windows-latest'
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Output ("##vso[task.setvariable variable=DeployEnvironment;isOutput=true]AnEnvironment")
Write-Output ("vso[task.setvariable variable=DeployEnvironment;isOutput=true]AnEnvironment")
name: varStep
- script: echo $(varStep.deployEnvironment)
name: show
- stage: secondStage
dependsOn: firstStage
variables:
- name: DeployEnvironmentstage
value: $[ stageDependencies.firstStage.varSetJob.outputs['varStep.DeployEnvironment'] ]
jobs:
- job: showvar
pool:
vmImage: 'windows-latest'
steps:
- script: echo $(DeployEnvironmentstage)
name: show
此管道无法启动第二步,并且未创建任何日志,并且在诊断模式下运行。
我已经检查过azure devops版本,它是最新的sprint版本。
有人在工作吗?
答案 0 :(得分:1)
尝试将变量放在Job下:
- stage: secondStage
dependsOn: firstStage
jobs:
- job: showvar
pool:
vmImage: 'windows-latest'
variables:
- name: DeployEnvironmentstage
value: $[ stageDependencies.firstStage.varSetJob.outputs['varStep.DeployEnvironment'] ]
steps:
- script: echo $(DeployEnvironmentstage)
name: show