-
Notifications
You must be signed in to change notification settings - Fork 54
/
azure-pipeline.yml
440 lines (389 loc) · 17.9 KB
/
azure-pipeline.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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
name: $(Build.BuildID) - dgca-verifier-app-android
trigger:
branches:
include:
- develop
- feature/*
- releases/*
pr:
branches:
include:
- develop
- releases/*
resources:
repositories:
- repository: dgca-app-core-android
type: github
name: eu-digital-green-certificates/dgca-app-core-android
ref: 'main'
endpoint: 'GitHub - it-eucert-team'
- repository: it-dgc-verificac19-sdk-android
type: github
name: ministero-salute/it-dgc-verificac19-sdk-android
ref: 'feature/initial-sdk'
endpoint: 'GitHub - it-eucert-team'
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Build
jobs:
- job: InitPipeline
steps:
- checkout: self
clean: true
- checkout: dgca-app-core-android
- checkout: it-dgc-verificac19-sdk-android
- task: Bash@3
displayName: set init value
name: checkBuildCommit
inputs:
targetType: 'inline'
script: |
echo "Check trigger pipeline var"
echo "commit message: $(Build.SourceVersionMessage)"
echo "##vso[task.setvariable variable=message;isOutput=true;]$(Build.SourceVersionMessage)"
GIT_MESSAGE="$(Build.SourceVersionMessage)"
BUILD_REASON=$(Build.Reason)
echo "buildReason: $BUILD_REASON"
echo "gitMessage: $GIT_MESSAGE"
echo "##vso[task.setvariable variable=build;isOutput=true;]$(build)"
echo "##vso[task.setvariable variable=debug;isOutput=true;]$(debug)"
echo "##vso[task.setvariable variable=release;isOutput=true;]$(release)"
echo "##vso[task.setvariable variable=appcenter;isOutput=true;]$(appcenter)"
echo "##vso[task.setvariable variable=store;isOutput=true;]$(store)"
if [[ ! BUILD_REASON == 'IndividualCI' ]]; then
echo "Set variable for Build Reason Individual CI"
if [[ ! $GIT_MESSAGE == *"#build"* ]]; then
echo "Not a build commit. Stopping the execution of the build job."
fi
if [[ $GIT_MESSAGE == *"#build-release"* ]]; then
echo "set variabili build e release a true"
echo "##vso[task.setvariable variable=build;isOutput=true;]true"
echo "##vso[task.setvariable variable=release;isOutput=true;]true"
fi
if [[ $GIT_MESSAGE == *"#build-debug"* ]]; then
echo "set variabili build e debug a true"
echo "##vso[task.setvariable variable=build;isOutput=true;]true"
echo "##vso[task.setvariable variable=debug;isOutput=true;]true"
fi
if [[ $GIT_MESSAGE == *"#appcenter"* ]]; then
echo "set variabili appcenter a true"
echo "##vso[task.setvariable variable=appcenter;isOutput=true;]true"
fi
if [[ $GIT_MESSAGE == *"#store"* ]]; then
echo "set variabili store a true"
echo "##vso[task.setvariable variable=store;isOutput=true;]true"
fi
fi
if [[ BUILD_REASON == 'PullRequest' ]]; then
echo "Set variable for Build Reason PullRequest "
echo "##vso[task.setvariable variable=build;isOutput=true;]true"
echo "##vso[task.setvariable variable=debug;isOutput=true;]true"
fi
- bash: |
echo 'message $(checkBuildCommit.message)'
echo 'build $(checkBuildCommit.build)'
echo 'debug $(checkBuildCommit.debug)'
echo 'release $(checkBuildCommit.release)'
echo 'appcenter $(checkBuildCommit.appcenter)'
echo 'store $(checkBuildCommit.store)'
displayName: check variables
- job: BuildApk
dependsOn: InitPipeline
condition: and(succeeded(), eq(dependencies.InitPipeline.outputs['checkBuildCommit.build'], 'true'))
variables:
build: $[ dependencies.InitPipeline.outputs['checkBuildCommit.build'] ]
debug: $[ dependencies.InitPipeline.outputs['checkBuildCommit.debug'] ]
release: $[ dependencies.InitPipeline.outputs['checkBuildCommit.release'] ]
appcenter: $[ dependencies.InitPipeline.outputs['checkBuildCommit.appcenter'] ]
store: $[ dependencies.InitPipeline.outputs['checkBuildCommit.store'] ]
steps:
- checkout: self
clean: true
- checkout: dgca-app-core-android
- checkout: it-dgc-verificac19-sdk-android
- task: ExtractVersionFromTag@1
inputs:
projectFolderPath: '$(Build.SourcesDirectory)/it-dgc-verificaC19-android'
# creo le variabili dal file appConfig.json tra cui il versionName
- task: oneLuckiDevJson2Variable@1
inputs:
jsonFile: '$(Build.SourcesDirectory)/it-dgc-verificaC19-android/appConfig.json'
shouldPrefixVariables: false
displayName: set variable name from appConfig.json
- bash: |
echo 'message $(message)'
echo 'build $(build)'
echo 'debug $(debug)'
echo 'release $(release)'
echo 'appcenter $(appcenter)'
echo 'store $(store)'
echo '$(NUMBER_OF_COMMITS)'
echo '$(versionName)-dev'
displayName: check variables
- task: UpdateAndroidVersionGradle@1
displayName: UpdateVersion -dev
condition: and(succeeded(), eq(variables.release, 'false'))
inputs:
buildGradlePath: 'it-dgc-verificaC19-android/app/build.gradle'
versionCode: '$(NUMBER_OF_COMMITS)'
versionName: '$(versionName)-dev'
- task: UpdateAndroidVersionGradle@1
displayName: UpdateVersion Release
condition: and(succeeded(), eq(variables.release, 'true'))
inputs:
buildGradlePath: 'it-dgc-verificaC19-android/app/build.gradle'
versionCode: '$(NUMBER_OF_COMMITS)'
versionName: '$(versionName)'
- task: SonarQubePrepare@4
inputs:
SonarQube: 'SonarQube Azure 8.9'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: '$(System.TeamProject)_it-dgc-verificaC19-android'
cliProjectName: '$(System.TeamProject)_it-dgc-verificaC19-android'
cliProjectVersion: '$(Build.SourceBranchName)_$(Build.SourceVersion)'
cliSources: '.'
extraProperties: |
sonar.java.binaries=.
sonar.exclusions=**/CCReport*/**
continueOnError: true
- task: SonarQubeAnalyze@4
continueOnError: true
condition: succeeded()
- task: SonarQubePublish@4
inputs:
pollingTimeoutSec: '300'
continueOnError: true
condition: succeeded()
- task: Gradle@2
displayName: Build Debug
condition: and(succeeded(), eq(variables.release, 'false'))
inputs:
gradleWrapperFile: 'it-dgc-verificaC19-android/gradlew'
workingDirectory: 'it-dgc-verificaC19-android'
tasks: 'assembleDebug'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
gradleOptions: '-Xmx3072m'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
- task: Gradle@2
displayName: Build Release
condition: and(succeeded(), eq(variables.release, 'true'))
inputs:
gradleWrapperFile: 'it-dgc-verificaC19-android/gradlew'
workingDirectory: 'it-dgc-verificaC19-android'
tasks: 'assembleRelease'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
gradleOptions: '-Xmx3072m'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
- task: CopyFiles@2
inputs:
contents: '**/*.apk'
targetFolder: '$(build.artifactStagingDirectory)'
- task: AndroidSigning@3
displayName: Sign apk debug
condition: and(succeeded(), eq(variables.release, 'false'))
inputs:
apkFiles: '$(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/apk/debug/app-debug.apk'
apksignerArguments: '--verbose --out $(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/apk/app-debug.apk'
zipalign: false
apksignerKeystoreFile: 'android-c19-key.jks'
apksignerKeystorePassword: '$(keystorepassword)'
apksignerKeystoreAlias: '$(keystorealias)'
apksignerKeyPassword: '$(keystorepassword)'
- task: AndroidSigning@3
displayName: Sign apk Release
condition: and(succeeded(), eq(variables.release, 'true'))
inputs:
apkFiles: '$(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/apk/release/app-release-unsigned.apk'
apksignerArguments: '--verbose --out $(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/apk/app-release.apk'
zipalign: false
apksignerKeystoreFile: 'android-c19-key.jks'
apksignerKeystorePassword: '$(keystorepassword)'
apksignerKeystoreAlias: '$(keystorealias)'
apksignerKeyPassword: '$(keystorepassword)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/apk'
artifact: 'apk'
publishLocation: 'pipeline'
- task: Gradle@2
displayName: build aab debug
inputs:
gradleWrapperFile: 'it-dgc-verificaC19-android/gradlew'
workingDirectory: 'it-dgc-verificaC19-android'
tasks: ':app:bundleDebug'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
gradleOptions: '-Xmx3072m'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
condition: and(succeeded(), eq(variables.store, 'true'), eq(variables.debug, 'true'))
- task: Gradle@2
displayName: build aab release
inputs:
gradleWrapperFile: 'it-dgc-verificaC19-android/gradlew'
workingDirectory: 'it-dgc-verificaC19-android'
tasks: ':app:bundleRelease'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
gradleOptions: '-Xmx3072m'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
condition: and(succeeded(), eq(variables.store, 'true'), eq(variables.release, 'true'))
- task: CopyFiles@2
inputs:
contents: '**/*.aab'
targetFolder: '$(build.artifactStagingDirectory)'
condition: and(succeeded(), eq(variables.store, 'true'))
- task: AndroidSigning@2
displayName: sign aab debug
inputs:
apkFiles: '$(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/bundle/debug/app-debug.aab'
jarsignerKeystoreFile: 'android-c19-key.jks'
jarsignerKeystorePassword: '$(keystorepassword)'
jarsignerKeystoreAlias: '$(keystorealias)'
jarsignerKeyPassword: '$(keystorepassword)'
jarsignerArguments: '-sigalg SHA256withRSA -digestalg SHA-256'
condition: and(succeeded(), eq(variables.store, 'true'), eq(variables.debug, 'true'))
- task: AndroidSigning@2
displayName: sign aab release
inputs:
apkFiles: '$(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/bundle/release/app-release.aab'
jarsignerKeystoreFile: 'android-c19-key.jks'
jarsignerKeystorePassword: '$(keystorepassword)'
jarsignerKeystoreAlias: '$(keystorealias)'
jarsignerKeyPassword: '$(keystorepassword)'
jarsignerArguments: '-sigalg SHA256withRSA -digestalg SHA-256'
condition: and(succeeded(), eq(variables.store, 'true'), eq(variables.release, 'true'))
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(build.artifactStagingDirectory)/it-dgc-verificaC19-android/app/build/outputs/bundle'
artifact: 'bundle'
publishLocation: 'pipeline'
condition: and(succeeded(), eq(variables.store, 'true'))
- task: PublishPipelineArtifact@1
inputs:
targetPath: 'it-dgc-verificaC19-android/metadata/release-notes.xml'
artifact: 'release-notes'
publishLocation: 'pipeline'
- stage: AppCenterRelease
dependsOn: Build
condition: eq(dependencies.Build.outputs['InitPipeline.checkBuildCommit.appcenter'], 'true')
variables:
build: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.build'] ]
debug: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.debug'] ]
release: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.release'] ]
appcenter: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.appcenter'] ]
store: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.store'] ]
jobs:
- deployment: AppCenterRelease # name of the deployment job, A-Z, a-z, 0-9, and underscore. The word "deploy" is a keyword and is unsupported as the deployment name.
displayName: Release to AppCenter # friendly name to display in the UI
workspace:
clean: all # what to clean up before the job runs
environment: AppCenter # target environment name and optionally a resource name to record the deployment history; format: <environment-name>.<resource-name>
strategy:
runOnce: #rolling, canary are the other strategies that are supported
preDeploy:
steps:
- script: |
echo "pre deploy to appcenter - var appcenter $(appcenter)"
echo 'build $(build)'
echo 'debug $(debug)'
echo 'release $(release)'
echo 'appcenter $(appcenter)'
echo 'store $(store)'
deploy:
steps:
- script: |
echo "deploy deploy to appcenter - var appcenter $(appcenter)"
- task: AppCenterDistribute@3
displayName: AppCenter debug Distribute
condition: and(succeeded(), eq(variables.debug, 'true'))
inputs:
serverEndpoint: 'DGC-App'
appSlug: 'sogei/it-dgc-verificaC19-android'
appFile: '$(Pipeline.Workspace)/apk/app-debug.apk'
symbolsOption: 'Android'
releaseNotesOption: 'file'
releaseNotesFile: '$(PIPELINE.WORKSPACE)/release-notes/release-notes.xml'
destinationType: 'groups'
isSilent: true
- task: AppCenterDistribute@3
displayName: AppCenter debug Distribute
condition: and(succeeded(), eq(variables.release, 'true'))
inputs:
serverEndpoint: 'DGC-App'
appSlug: 'sogei/it-dgc-verificaC19-android'
appFile: '$(Pipeline.Workspace)/apk/app-release.apk'
symbolsOption: 'Android'
releaseNotesOption: 'file'
releaseNotesFile: '$(PIPELINE.WORKSPACE)/release-notes/release-notes.xml'
destinationType: 'groups'
isSilent: true
- stage: GooglePlayTestRelease
dependsOn: Build
condition: eq(dependencies.Build.outputs['InitPipeline.checkBuildCommit.store'], 'true')
variables:
build: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.build'] ]
debug: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.debug'] ]
release: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.release'] ]
appcenter: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.appcenter'] ]
store: $[ stageDependencies.Build.InitPipeline.outputs['checkBuildCommit.store'] ]
jobs:
- deployment: GooglePlayRelease # name of the deployment job, A-Z, a-z, 0-9, and underscore. The word "deploy" is a keyword and is unsupported as the deployment name.
displayName: Release to Google Play # friendly name to display in the UI
workspace:
clean: all # what to clean up before the job runs
environment: AndroidStoreTest # target environment name and optionally a resource name to record the deployment history; format: <environment-name>.<resource-name>
strategy:
runOnce: #rolling, canary are the other strategies that are supported
preDeploy:
steps:
- script: |
echo "pre deploy to store - var store $(store)"
echo 'build $(build)'
echo 'debug $(debug)'
echo 'release $(release)'
echo 'appcenter $(appcenter)'
echo 'store $(store)'
displayName: check variables
deploy:
steps:
- script: |
echo "deploy to store - var store $(store)"
cd $(Pipeline.Workspace)/bundle/debug
ls -l
cd $(Pipeline.Workspace)/bundle/release
ls -l
displayName: check download artifact
- task: GooglePlayReleaseBundle@3
condition: and(succeeded(), eq(variables.store, 'true'), eq(variables.debug, 'true'))
displayName: Publish Debug version to store
inputs:
serviceConnection: 'verificac19-google-play'
applicationId: 'it.ministerodellasalute.verificaC19'
bundleFile: '$(Pipeline.Workspace)/bundle/debug/app-debug.aab'
track: 'internal'
changeLogFile: '$(Pipeline.Workspace)/release-notes/release-notes.xml'
languageCode: 'en-GB'
- task: GooglePlayReleaseBundle@3
condition: and(succeeded(), eq(variables.store, 'true'), eq(variables.release, 'true'))
displayName: Publish Release version to store
inputs:
serviceConnection: 'verificac19-google-play'
applicationId: 'it.ministerodellasalute.verificaC19'
bundleFile: '$(Pipeline.Workspace)/bundle/release/app-release.aab'
track: 'internal'
changeLogFile: '$(Pipeline.Workspace)/release-notes/release-notes.xml'
languageCode: 'en-GB'