-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipeline.yaml
104 lines (87 loc) · 2.94 KB
/
azure-pipeline.yaml
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
trigger: none
pr: none
pool:
vmImage: ubuntu-latest
variables:
workingDir: 'myDir'
npm_config_cache: $(Pipeline.Workspace)/$(workingDir)/.npm
myBooleanVar: 'true'
myStringVar: 'abc'
myIntegerVar: '123'
stages:
- stage: 'stage1'
displayName: 'Stage 1'
dependsOn: []
condition: and(succeededOrFailed(), ne(variables['Build.Reason'], 'Schedule'))
jobs:
- job: 'job1'
displayName: 'Job 1 - Create hello.txt and save to artifact'
steps:
- bash: ls
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'List myDirectory'
- bash: touch hello.txt
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'Create a hello.txt file'
- bash: echo "Hello" > hello.txt
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'Put "hello" into hello.txt'
- script: |
ls
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'List myDirectory'
- task: CopyFiles@2
displayName: 'Save hello.txt as artifact'
inputs:
contents: '$(myDirectory)/hello.txt'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- publish: '$(Build.ArtifactStagingDirectory)/$(myDirectory)'
displayName: 'Publish artifact'
artifact: 'hello'
- job: 'job2'
displayName: 'Job 2 - Build & Cache NodeJS'
steps:
- task: Cache@2
inputs:
key: 'version1 | "$(Agent.OS)" | $(myDirectory)/package.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: '$(Build.SourcesDirectory)/$(myDirectory)/node_modules'
cacheHitVar: CACHE_RESTORED
- task: NodeTool@0
inputs:
versionSpec: '18.x'
checkLatest: true
displayName: 'Install NodeJS'
condition: ne(variables.CACHE_RESTORED, 'true')
- script: npm i smallest
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'Install NodeJS Dependencies'
condition: ne(variables.CACHE_RESTORED, 'true')
- bash: ls
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'List myDirectory'
- stage: 'stage2'
displayName: 'Stage 2'
dependsOn: []
condition: succeededOrFailed()
jobs:
- job: 'job1'
displayName: 'Job 1 - Reuse an artifact'
variables:
myVariable: 'Bye'
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: 'hello'
path: '$(Build.SourcesDirectory)/$(myDirectory)'
condition: ne(variables.CACHE_RESTORED, 'true')
- bash: ls
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'List myDirectory'
- bash: echo $(myVariable) >> hello.txt
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'Append test variable into hello.txt'
- bash: cat hello.txt
workingDirectory: '$(Build.SourcesDirectory)/$(myDirectory)'
displayName: 'Display contents of hello.txt'