is it possible to declare a variable and then pass it downstream? I have an image below StageA -> StageB -> StageC where I obtain a url for my storage account on StageA, and I want to use it for both Stage B and StageC
But if I use the [stagedependencies.StageA.JobA.outputs['var'], it only works on StageB and not on 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)
Maybe I missed it somewhere but does this mean you can only obtain the variable from the immediate stage you depend?
Example:
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)