forked from shashban/AzurePipelineSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sequentialphases_outputvariables.yml
39 lines (38 loc) · 1.59 KB
/
sequentialphases_outputvariables.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# A pipeline with three sequential jobs
# Output variables from previous jobs are being referred
jobs:
- job: A
pool: Hosted VS2017
steps:
- checkout: none
- powershell: echo "##vso[task.setvariable variable=myOutputVarA;isOutput=true]I was set in Job A"
name: setoutputvar
displayName: 'set output variable'
- powershell: Write-Host 'Variable set in this job - ' + $(setoutputvar.myOutputVarA)
displayName: 'Run a script'
- job: B
dependsOn: A
pool: Hosted VS2017
variables:
myVarFromJobA: $[dependencies.A.outputs['setoutputvar.myOutputVarA']]
steps:
- powershell: echo "##vso[task.setvariable variable=myOutputVarB;isOutput=true]I was set in Job B"
name: setoutputvar
displayName: 'set output variable'
- powershell: |
Write-Host 'Variable obtained from Job A - $(myVarFromJobA)'
Write-Host 'Variable set in this job - $(setoutputvar.myOutputVarB)'
displayName: 'Print variables'
- job: C
dependsOn: B
pool: Hosted VS2017
variables:
myVarFromJobA: $[dependencies.A.outputs['setoutputvar.myOutputVarA']]
# myVarFromJobA would be empty as job C does not depend on job A
myVarFromJobB: $[dependencies.B.outputs['setoutputvar.myOutputVarB']]
steps:
- powershell: |
Write-Host "Accessing variables from dependent jobs"
Write-Host 'Variable set in Job A says - $(myVarFromJobA)'
Write-Host 'Variable set on Job B says - $(myVarFromJobB)'
displayName: 'Print variables'