0

我正在尝试使新的阶段变量起作用。这是我的精简示例:-

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 版本。

有人有这个工作吗?

4

1 回答 1

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
于 2020-05-21T02:32:16.633 回答