forked from asastech/Open-Banking-SandBox-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
505 lines (454 loc) · 15.9 KB
/
.gitlab-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
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
---
# yamllint disable rule:line-length
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Global settings
image: "adorsys/ci-build:latest"
# ------------------------------------------------------------------
# stages
# ------------------------------------------------------------------
stages:
- "Lint"
- "Compile" # build jar and provide as artifact
- "Test" # run tests and code quality checks
- "Package" # dockerize jar and push to docker registry
- "Deploy" # push to openshift registry
- "release" # release
# ------------------------------------------------------------------
# variables
# ------------------------------------------------------------------
variables:
SONAR_HOST: "https://psd2-quality.cloud.adorsys.de"
GIT_SUBMODULE_STRATEGY: normal
# Online banking
DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING: "xs2a-online-banking"
DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING_UI: "xs2a-online-banking-ui"
DOCKER_IMAGE_NAME_XS2A_TPP_UI: "xs2a-bank-tpp-ui"
DOCKER_IMAGE_NAME_XS2A_DEVPORTAL_UI: "xs2a-bank-devportal"
DOCKER_IMAGE_NAME_XS2A_TPP_REST_SERVER: "xs2a-tpp-rest-server"
###########################
# Public Dockerhub Images #
###########################
DOCKERHUB_REGISTRY: "docker.io"
DOCKERHUB_NAMESPACE: "adorsys"
############################
# Private Openshift Images #
############################
OPENSHIFT_NAMESPACE_ADORSYS_MODELBANK_DEV: "adorsys-modelbank-dev"
OPENSHIFT_NAMESPACE_ADORSYS_MODELBANK_E2E: "adorsys-modelbank-e2e"
###########################
# Build variables #
###########################
# Defaults for Java 11
JAVA_TOOL_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:MaxRAM=3G -XX:MaxRAMFraction=3"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# ------------------------------------------------------------------
# reusable yaml anchors
# ------------------------------------------------------------------
.build_java: &build_java
stage: "Compile"
script:
- jabba use $BUILD_JAVA_VERSION
- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- make build-java-services
cache:
key: "Java_${CI_COMMIT_REF_SLUG}"
paths:
- /builds/adorsys/xs2a/psd2-dynamic-sandbox/.m2/repository
# Build docker images and put them to DOCKER HUB repo
.build_docker_images: &build_docker_images
script:
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING}:${DOCKER_TAG}" online-banking/online-banking-app
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING_UI}:${DOCKER_TAG}" oba-ui
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_REST_SERVER}:${DOCKER_TAG}" tpp-app/tpp-rest-server
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_UI}:${DOCKER_TAG}" tpp-ui
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_DEVPORTAL_UI}:${DOCKER_TAG}" developer-portal-ui
.push_dockerhub_images: &push_dockerhub_images
script:
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING}:${DOCKER_TAG}" online-banking/online-banking-app
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING_UI}:${DOCKER_TAG}" oba-ui
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_REST_SERVER}:${DOCKER_TAG}" tpp-app/tpp-rest-server
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_UI}:${DOCKER_TAG}" tpp-ui
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_DEVPORTAL_UI}:${DOCKER_TAG}" developer-portal-ui
- docker login -u $DOCKER_HUB_LOGIN -p $DOCKER_HUB_PASS
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING_UI}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_REST_SERVER}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_UI}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_DEVPORTAL_UI}:${DOCKER_TAG}"
- docker logout
# Copy Dockerhub images to Openshift (depending on ${DOCKER_TAG})
.deploy_openshift: &deploy_openshift
script:
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING}:latest"
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING_UI}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_ONLINE_BANKING_UI}:latest"
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_REST_SERVER}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_REST_SERVER}:latest"
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_UI}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_TPP_UI}:latest"
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_DEVPORTAL_UI}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_DEVPORTAL_UI}:latest"
# ------------------------------------------------------------------
# jobs
# ------------------------------------------------------------------
#-------------------------------------------------------------------
# lint
#-------------------------------------------------------------------
Lint:Dockerfiles:
image: docker:20.10
stage: "Lint"
services:
- docker:20.10-dind
except:
- schedules
- develop
- master
script:
- apk add make
- echo "Run Dockerfiles lint"
- make lint-dockerfiles
Lint:OBA_frontend:
image: node:12.16.2-stretch-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- >-
apt-get update && apt-get install
jsonlint yamllint libxml2-utils
make curl -yq && ln -s /usr/bin/jsonlint-php /usr/bin/jsonlint
- echo "Run OBA lint"
- make lint-oba-ui
Lint:TPP_frontend:
image: node:12.16.2-stretch-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt-get update && apt-get install jsonlint yamllint libxml2-utils make curl -yq && ln -s /usr/bin/jsonlint-php /usr/bin/jsonlint
- echo "Run TPP lint"
- make lint-tpp-ui
Lint:Devportal_frontend:
image: node:12.16.2-stretch-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt-get update && apt-get install jsonlint yamllint libxml2-utils make curl -yq && ln -s /usr/bin/jsonlint-php /usr/bin/jsonlint
- echo "Run Devportal frontend lint"
- make lint-developer-portal-ui
Lint:OBA_backend:
image: debian:stretch-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt-get update && apt-get install --no-install-recommends jsonlint yamllint libxml2-utils make curl -yq && ln -s /usr/bin/jsonlint-php /usr/bin/jsonlint
- echo "Run OBA backend lint"
- make lint-online-banking
Lint:TPP_backend:
image: debian:stretch-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt-get update && apt-get install jsonlint yamllint libxml2-utils make curl -yq && ln -s /usr/bin/jsonlint-php /usr/bin/jsonlint
- echo "Run TPP backend lint"
- make lint-tpp-rest-server
Lint:Docker_compose:
image: maven:3.6-jdk-11-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt update && apt install yamllint docker-compose make -yq
- echo "Run Docker compose lint"
- make lint-docker-compose
Build:OBA_frontend:
image: node:12.16.2-stretch-slim
stage: "Compile"
except:
- schedules
script:
- apt-get update && apt-get install make libxml2-utils jq -yq
- echo "Update info.json"
- VERSION=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
- jq --arg VERSION "$VERSION" --arg BUILD_ID "$CI_PIPELINE_ID" '.version = $VERSION | .build_number = $BUILD_ID' oba-ui/info.json >> info.json
- mv info.json oba-ui/info.json
- echo "Run OBA frontend Build"
- make npm-install-oba-ui
cache: {}
artifacts:
paths:
- "oba-ui/dist"
- "oba-ui/info.json"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}"
expire_in: "1 day"
Build:TPP_frontend:
image: node:12.16.2-stretch-slim
stage: "Compile"
except:
- schedules
script:
- apt-get update && apt-get install make jq libxml2-utils -yq
- echo "Update info.json"
- VERSION=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
- jq --arg VERSION "$VERSION" --arg BUILD_ID "$CI_PIPELINE_ID" '.version = $VERSION | .build_number = $BUILD_ID' tpp-ui/info.json >> info.json
- mv info.json oba-ui/info.json
- echo "Run TPP frontend Build"
- make npm-install-tpp-ui
cache: {}
artifacts:
paths:
- "tpp-ui/dist"
- "tpp-ui/info.json"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}"
expire_in: "1 day"
Build:Devportal_frontend:
image: node:12.16.2-stretch-slim
stage: "Compile"
except:
- schedules
script:
- apt-get update && apt-get install zip make jq libxml2-utils -yq
- echo "Update info.json"
- VERSION=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
- jq --arg VERSION "$VERSION" --arg BUILD_ID "$CI_PIPELINE_ID" '.version = $VERSION | .build_number = $BUILD_ID' developer-portal-ui/info.json >> info.json
- mv info.json developer-portal-ui/info.json
- echo "Update postman test files"
- scripts/.update-postman-test-files.sh
- echo "Run Devportal frontend Build"
- make npm-install-developer-portal-ui
cache: {}
artifacts:
paths:
- "developer-portal-ui/dist"
- "developer-portal-ui/info.json"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}"
expire_in: "1 day"
Build:Java11:
<<: *build_java
except:
- schedules
cache: {}
variables:
BUILD_JAVA_VERSION: system@1.11
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
artifacts:
paths:
- "online-banking/online-banking-app/target/online-banking-app.jar"
- "certificate-generator/target/certificate-generator.jar"
- "tpp-app/tpp-rest-server/target/tpp-rest-server.jar"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}"
expire_in: "1 day"
Lint:PMD_CPD_Report:
image: maven:3.6-jdk-11-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt update && apt install make -yq
- echo "Test java code for PMD and CPD"
- make lint-pmd-cpd-report
cache: {}
artifacts:
paths:
- "qa/pmd/pmd-ruleset.xml"
- "**/**/*/pmd.html"
- "**/*/pmd.xml"
name: "${CI_PROJECT_NAME}-${CI_BUILD_REF_NAME#*v}-pmd"
expire_in: "10 day"
Doc Check Java11:
stage: "Test"
except:
- schedules
- develop
needs: ["Build:Java11"]
variables:
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
JAVA_VERSION: "system@1.11"
script:
- jabba use ${JAVA_VERSION}
- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp --settings scripts/mvn-release-settings.xml -Dmaven.test.skip=true -Pjavadoc verify javadoc:javadoc
UnitTests:Java11:
image: maven:3.6-jdk-11-slim
stage: "Test"
except:
- schedules
- develop
needs: ["Build:Java11"]
variables:
JAVA_VERSION: "system@1.11"
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
script:
- apt update && apt install make -yq
- echo "Run unit tests for backend"
- make unit-tests-backend
UnitTests:DevPortal_frontend:
image: node:12.16.2-stretch-slim
stage: "Test"
except:
- schedules
needs: ["Build:Devportal_frontend"]
variables:
CHROME_BIN: "/usr/bin/chromium"
script:
- apt-get update && apt-get install make chromium chromium-l10n -yq
- echo 'Unit tests Devportal frontend'
- make unit-tests-developer-portal-ui
UnitTests:TPP_frontend:
image: node:12.16.2-stretch-slim
stage: "Test"
except:
- schedules
needs: ["Build:TPP_frontend"]
variables:
CHROME_BIN: "/usr/bin/chromium"
script:
- apt-get update && apt-get install make chromium chromium-l10n -yq
- echo 'Unit tests TPP frontend'
- make unit-tests-tpp-ui
UnitTests:OBA_frontend:
image: node:12.16.2-stretch-slim
stage: "Test"
except:
- schedules
needs: ["Build:OBA_frontend"]
variables:
CHROME_BIN: "/usr/bin/chromium"
script:
- apt-get update && apt-get install make chromium chromium-l10n -yq
- echo 'Unit tests OBA frontend'
- make unit-tests-oba-ui
Test:Build_docker_images:
stage: "Test"
except:
- schedules
needs:
[
"Build:OBA_frontend",
"Build:TPP_frontend",
"Build:Devportal_frontend",
"Build:Java11",
]
variables:
DOCKER_TAG: test
<<: *build_docker_images
Postman Tests:
stage: "Test"
only:
- schedules
image:
name: postman/newman_alpine33
entrypoint: [""]
script:
- npm config set unsafe-perm true
- npm install -g newman-reporter-html
- cd postman
- newman run postman_collection.json -e postman_environment_dev.json -g postman_global_variable.json --reporters cli,html --reporter-html-template html_report_template.hbs --reporter-html-export postman-tests-report.html --suppress-exit-code
artifacts:
when: always
paths:
- "postman/postman-tests-report.html"
expire_in: "10 day"
# develop
Sonarcube Tests:
stage: "Test"
except:
- schedules
only:
- develop
needs: []
script:
- jabba use system@1.11
- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp --fail-at-end clean install
- mvn sonar:sonar -Dsonar.host.url=${SONAR_HOST} -Dsonar.login=${SONAR_TOKEN}
build_dockerhub_image_develop:
stage: "Package"
except:
- schedules
only:
- develop
variables:
DOCKER_TAG: develop
<<: *push_dockerhub_images
##########
# deploy #
##########
deploy_openshift_develop:
stage: "Deploy"
except:
- schedules
only:
- develop
variables:
DOCKER_TAG: develop # Dockerhub source tag
OPENSHIFT_NAMESPACE: ${OPENSHIFT_NAMESPACE_ADORSYS_MODELBANK_DEV} # Openshift target namespace
<<: *deploy_openshift
###########
# nightly #
###########
deploy_openshift_nightly:
stage: "Deploy"
only:
- schedules
variables:
DOCKER_TAG: develop # Dockerhub source tag
OPENSHIFT_NAMESPACE: ${OPENSHIFT_NAMESPACE_ADORSYS_MODELBANK_E2E} # Openshift target namespace
<<: *deploy_openshift
##########
# master #
##########
build_dockerhub_image_master:
stage: "Package"
only:
- master
variables:
DOCKER_TAG: latest
<<: *push_dockerhub_images
########
# tags #
########
build_dockerhub_images_from_tag:
stage: "Package"
only:
- tags
variables:
DOCKER_TAG: ${CI_COMMIT_TAG}
<<: *push_dockerhub_images