-
Notifications
You must be signed in to change notification settings - Fork 101
/
azure-pipelines-ci.yml
297 lines (292 loc) · 11.6 KB
/
azure-pipelines-ci.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
pr:
drafts: false
trigger:
- none
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
# Agent VM image name
- name: vmImageName
value: 'windows-latest'
- name: fullBuild
value: $[ne(variables['Build.Reason'], 'PullRequest')]
- name: securityScan
value: $[or(eq(variables['Build.Reason'], 'Manual'), eq(variables['Build.Reason'], 'Schedule'))]
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
- task: Npm@1
inputs:
command: 'install'
workingDir: 'react'
- task: Npm@1
inputs:
command: 'custom'
workingDir: 'react'
customCommand: 'run pub'
- task: CodeInspector@2
displayName: "[Security Review] code inspector"
inputs:
ProductId: '606a5e0d-64b0-4237-9dca-eac200438452'
condition: eq(variables.securityScan, 'true')
- task: CodeQL3000Init@0
displayName: "[Security Review] CodeQL Init"
condition: eq(variables.securityScan, 'true')
- task: CredScan@3
displayName: "[Security Review] CredScan"
condition: eq(variables.securityScan, 'true')
- task: PowerShell@2
displayName: Generate Env File
inputs:
targetType: 'inline'
script: |
if(Test-Path variable:BLOB_CONNECTION_STRING){
New-Item -Path common/src/test/resources -Name ".env" -ItemType "file" -Value "BLOB_CONNECTION_STRING = $(BLOB_CONNECTION_STRING)"
}else{
Write-Host "No BLOB_CONNECTION_STRING found"
}
workingDirectory: '$(Build.Repository.LocalPath)'
condition: eq(variables.fullBuild, 'false')
- task: PowerShell@2
displayName: Set center/agent version
inputs:
targetType: 'inline'
script: |
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
$hydraVersionCode = $(Build.BuildId)
$hydraVersion = "$(Build.SourceBranchName).$(Build.BuildId)"
$branchName = "$(Build.SourceBranch)"
(Get-Content agent/src/main/resources/version.properties) -Replace '1000000', "$hydraVersionCode"| Set-Content agent/src/main/resources/version.properties
(Get-Content center/src/main/resources/version.properties) -Replace '1000000', "$hydraVersionCode"| Set-Content center/src/main/resources/version.properties
if($branchName -like '*Release*'){
(Get-Content agent/src/main/resources/version.properties) -Replace '0.0.0', $hydraVersion| Set-Content agent/src/main/resources/version.properties
(Get-Content center/src/main/resources/version.properties) -Replace '0.0.0', $hydraVersion| Set-Content center/src/main/resources/version.properties
}
echo "##vso[task.setvariable variable=hydraVersionCode;]$hydraVersionCode"
echo "##vso[task.setvariable variable=hydraVersion;]$hydraVersion"
workingDirectory: '$(Build.Repository.LocalPath)'
- task: Gradle@3
displayName: Run JUnit Test
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'test jacocoRootReport --stacktrace'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
#codeCoverageToolOption: 'JaCoCo'
#codeCoverageClassFilesDirectories: 'build/classes/java/main'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
condition: eq(variables.fullBuild, 'false')
- task: PowerShell@2
displayName: Delete Env File
inputs:
targetType: 'inline'
script: |
if(Test-Path common/src/test/resources/.env){
Remove-Item -Path common/src/test/resources/.env -Force
}else{
Write-Host "No .env file found"
}
workingDirectory: '$(Build.Repository.LocalPath)'
condition: eq(variables.fullBuild, 'false')
- task: PublishCodeCoverageResults@1
displayName: Publich Code Coverage
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'build/reports/jacoco/jacocoRootReport/*.xml'
reportDirectory: 'build/reports/jacoco/jacocoRootReport/html'
condition: eq(variables.fullBuild, 'false')
- task: Gradle@2
displayName: Package Android client APK
inputs:
workingDirectory: 'android_client'
gradleWrapperFile: 'android_client/gradlew'
tasks: 'assembleRelease --stacktrace'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
options: '-PclientVersionCode=$(hydraVersionCode) -PclientVersionNumber=$(hydraVersion)'
- task: Gradle@2
displayName: Package Android client APK
inputs:
workingDirectory: 'android_client'
gradleWrapperFile: 'android_client/gradlew'
tasks: 'assembleAndroidTest --stacktrace'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
options: '-PclientVersionCode=$(hydraVersionCode) -PclientVersionNumber=$(hydraVersion)'
- task: PowerShell@2
displayName: Copy APK to folder for deployment
inputs:
targetType: 'inline'
script: |
cp android_client/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk common/src/main/resources/record_androidTest.apk -force
- task: PowerShell@2
displayName: Copy APK to folder for deployment
inputs:
targetType: 'inline'
script: |
cp android_client/app/build/outputs/apk/release/app-release.apk common/src/main/resources/record_release.apk -force
- task: Gradle@2
displayName: Build center
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'center:bootJar --stacktrace'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
- task: Gradle@2
displayName: Build agent
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'agent:bootJar --stacktrace'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
- task: CopyFiles@2
displayName: Copy deploy center files
inputs:
SourceFolder: 'center/'
Contents: 'Dockerfile'
TargetFolder: '$(Build.ArtifactStagingDirectory)/center_deploy'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy deploy center files 2
inputs:
SourceFolder: 'center/deploy_startup/'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)/center_deploy/deploy_startup'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy deploy center files 3
inputs:
SourceFolder: 'center/uber_image/'
Contents: 'hydra_lab_center_docker_db.sqlite'
TargetFolder: '$(Build.ArtifactStagingDirectory)/center_deploy/deploy_startup'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy deploy center files 4
inputs:
SourceFolder: 'common/src/main/resources/'
Contents: |
record_release.apk
record_androidTest.apk
TargetFolder: '$(Build.ArtifactStagingDirectory)/center_deploy/deploy_startup'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy center jar
inputs:
SourceFolder: 'center/build/libs/'
Contents: '*.jar'
TargetFolder: '$(Build.ArtifactStagingDirectory)/center_deploy'
condition: eq(variables.fullBuild, 'true')
- task: Gradle@2
displayName: Package Mac installer
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'packageMacInstaller --stacktrace'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
condition: eq(variables.fullBuild, 'true')
- task: Gradle@2
displayName: Package Windows installer
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'packageWindowsInstaller --stacktrace'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
condition: eq(variables.fullBuild, 'true')
- task: PowerShell@2
displayName: Copy APK & Mapping file to artifact
inputs:
targetType: 'inline'
script: |
mkdir -p $(Build.ArtifactStagingDirectory)/android_client
cp android_client/app/build/outputs/apk/release/app-release.apk $(Build.ArtifactStagingDirectory)/android_client/app-release-$(hydraVersion).apk
if(Test-Path android_client/app/build/outputs/mapping/release/mapping.txt){
cp android_client/app/build/outputs/mapping/release/mapping.txt $(Build.ArtifactStagingDirectory)/android_client/
}
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy agent jar
inputs:
SourceFolder: 'agent/build/libs/'
Contents: '*.jar'
TargetFolder: '$(Build.ArtifactStagingDirectory)/agent_deploy'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy agent installer
inputs:
SourceFolder: 'build/installer/'
Contents: '*.zip'
TargetFolder: '$(Build.ArtifactStagingDirectory)/agent_deploy'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy deploy uber files 1
inputs:
SourceFolder: 'common/src/main/resources/'
Contents: |
record_release.apk
record_androidTest.apk
TargetFolder: '$(Build.ArtifactStagingDirectory)/uber_image'
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy deploy uber files 2
inputs:
SourceFolder: 'center/uber_image/'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)/uber_image'
condition: eq(variables.fullBuild, 'true')
- task: PowerShell@2
displayName: Add Release Tag
inputs:
targetType: 'inline'
script: |
Write-Host "##vso[build.addbuildtag]Release"
workingDirectory: '$(Build.Repository.LocalPath)'
condition: and(eq(variables.fullBuild, 'true'), contains(variables['Build.SourceBranch'], 'Release/'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'HydraLabRelease'
publishLocation: 'Container'
condition: eq(variables.fullBuild, 'true')
- task: CodeQL3000Finalize@0
displayName: "[Security Review] CodeQL Finalize"
condition: eq(variables.securityScan, 'true')
- task: securedevelopmentteam.vss-secure-development-tools.build-task-report.SdtReport@2
# https://strikecommunity.azurewebsites.net/articles/8216/how-to-enable-build-break-on-credscan-detections.html
displayName: "[Security Review] Create CredScan Security Analysis Report"
inputs:
GdnExportHtmlFile: true
GdnExportAllTools: false
GdnExportGdnToolBinSkim: true
GdnExportGdnToolCredScan: true
GdnExportGdnToolSemmle: true
condition: eq(variables.securityScan, 'true')