【发布时间】:2021-05-22 11:27:25
【问题描述】:
是否可以声明一个变量然后将其传递给下游? 我在 StageA -> StageB -> StageC 下面有一张图片 我在 StageA 上获取我的存储帐户的 url,我想将它用于 Stage B 和 StageC
但如果我使用[stagedependencies.StageA.JobA.outputs['var'],它只适用于StageB,不适用于StageC
- stage: 'StageC'
dependsOn: 'StageB'
pool:
vmImage: 'windows-latest'
variables:
blobUri: $[stageDependencies.StageA.JobA.outputs['createOutput.blobUri']]
jobs:
- job: 'JobC'
steps:
- checkout: none
- download: none
- powershell: |
echo JobBUri: $(blobUri)
也许我在某个地方错过了它,但这是否意味着您只能从您依赖的直接阶段获取变量?
例子:
trigger:
- master
pool:
vmImage: ubuntu-latest
stages:
- stage: 'StageA'
jobs:
- job: 'JobA'
steps:
- task: Powershell@2
name: 'createOutput'
inputs:
targetType: 'inline'
script: |
Write-Output "##vso[task.setvariable variable=blobUri;isOutput=true]www.google.com"
- stage: 'StageB'
dependsOn: 'StageA'
pool:
vmImage: 'windows-latest'
variables:
blobUri: $[stageDependencies.StageA.JobA.outputs['createOutput.blobUri']]
jobs:
- job: 'JobB'
steps:
- powershell: |
echo JobBUri: $(blobUri)
- stage: 'StageC'
dependsOn: 'StageB'
pool:
vmImage: 'windows-latest'
variables:
blobUri: $[stageDependencies.StageA.JobA.outputs['createOutput.blobUri']]
jobs:
- job: 'JobC'
steps:
- powershell: |
echo JobBUri: $(blobUri)
【问题讨论】:
标签: azure azure-devops yaml azure-pipelines azure-pipelines-yaml