forked from adorsys/xs2a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
391 lines (343 loc) · 12.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
---
# yamllint disable rule:line-length
# ------------------------------------------------------------------
# Global settings
# ------------------------------------------------------------------
image: "adorsys/ci-build:latest"
# ------------------------------------------------------------------
# stages
# ------------------------------------------------------------------
stages:
- "Lint" # Lint files and configuration
- "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 (snapshot deployment) or release registry
- "Notification" # Notify to specific channel about applications versions
# ------------------------------------------------------------------
# variables
# ------------------------------------------------------------------
variables:
SONAR_HOST: "https://psd2-quality.cloud.adorsys.de"
DOCKER_IMAGE_NAME_CNT_MGMNT: "xs2a-consent-management"
DOCKER_IMAGE_NAME_ASPSP_PROFILE: "xs2a-aspsp-profile"
DOCKER_IMAGE_NAME_XS2A: "xs2a-service"
DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR: "xs2a-certificate-generator"
###########################
# Public Dockerhub Images #
###########################
DOCKERHUB_REGISTRY: "docker.io"
DOCKERHUB_NAMESPACE: "adorsys"
############################
# Private Openshift Images #
############################
OPENSHIFT_NAMESPACE_SUPPORT: "multibanking-xs2a"
OPENSHIFT_NAMESPACE_ADORSYS_XS2A_DEV: "adorsys-xs2a-dev"
OPENSHIFT_NAMESPACE_ADORSYS_XS2A_INTEG: "adorsys-xs2a-integ"
###########################
# Build variables #
###########################
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
script:
- jabba use ${JAVA_VERSION}
- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
- env BUILD_NUMBER=$CI_PIPELINE_IID ./scripts/set_xs2a_connector_version_in_swagger.sh
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp -DskipITs -DskipTests -Dci.build.number=Build\:${CI_PIPELINE_ID} clean install
.java_tests: &java_tests
script:
- jabba use $JAVA_VERSION
- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp -DskipITs --fail-at-end clean install -q
# Build docker images and push them to Dockerhub (depending on ${DOCKER_TAG})
.build_dockerhub_image: &build_dockerhub_image
script:
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CNT_MGMNT}:${DOCKER_TAG}" consent-management/cms-standalone-service
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_ASPSP_PROFILE}:${DOCKER_TAG}" aspsp-profile/aspsp-profile-server
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A}:${DOCKER_TAG}" xs2a-standalone-starter
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR}:${DOCKER_TAG}" certificate-generator
- docker login -u ${DOCKER_HUB_LOGIN} -p ${DOCKER_HUB_PASS}
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CNT_MGMNT}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_ASPSP_PROFILE}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR}:${DOCKER_TAG}"
- docker logout
# Copy Dockerhub images to Openshift (depending on ${DOCKER_TAG} and ${OPENSHIFT_NAMESPACE})
.deploy_openshift: &deploy_openshift
script:
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CNT_MGMNT}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_CNT_MGMNT}:latest"
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_ASPSP_PROFILE}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_ASPSP_PROFILE}:latest"
- >-
skopeo copy
--dest-creds=openshift:${OPENSHIFT_TOKEN}
"docker://${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR}:${DOCKER_TAG}"
"docker://${OPENSHIFT_REGISTRY}/${OPENSHIFT_NAMESPACE}/${DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR}:latest"
# ------------------------------------------------------------------
# jobs
# ------------------------------------------------------------------
#-------------------------------------------------------------------
# lint
#-------------------------------------------------------------------
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"
- docker-compose -f docker-compose.yml config -q
Lint:Ci_file:
image: debian:stretch-slim
stage: "Lint"
except:
- schedules
- develop
- master
script:
- apt-get update && apt-get install yamllint python3-pkg-resources -yq
- echo "Run Gitlab ci file lint"
- yamllint -d relaxed .gitlab-ci.yml
Lint:XS2A_yaml_json_xml:
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 Xs2A core lint"
- find ./ -type f -name "*.json" -exec jsonlint -q {} \; # lint all json
# commented cause get many small errors for yaml with spaces empty lines and etc
# - find ./ -type f \( -name "*.yml" -o -name "*.yaml" \) -exec yamllint -d "{extends: relaxed, rules: {line-length: {max: 160}}}" {} \;
# commented cause get error Unsupported version '1.1'
# - find ./ -type f \( -iname "*.xml" ! -iname pom.xml \) -exec xmllint --noout {} \;
Lint:XS2A_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"
- echo "DOCKER_HOST=$DOCKER_HOST"
- mvn -ntp -Dmaven.test.skip=true package pmd:check # commented cause many duplications pmd:cpd-check
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"
Lint:XS2A_core_dockerfiles:
image: docker:20.10
stage: "Lint"
services:
- docker:20.10-dind
except:
- schedules
- develop
- master
script:
- echo "Run Xs2a core dockerfile check"
- docker run --rm -i hadolint/hadolint < ./consent-management/cms-standalone-service/Dockerfile
- docker run --rm -i hadolint/hadolint < ./aspsp-profile/aspsp-profile-server/Dockerfile
- docker run --rm -i hadolint/hadolint < ./xs2a-standalone-starter/Dockerfile
- docker run --rm -i hadolint/hadolint < ./certificate-generator/Dockerfile
#-------------------------------------------------------------------
# Compile
#-------------------------------------------------------------------
Build:XS2A_Java11:
stage: "Compile"
except:
- schedules
variables:
JAVA_VERSION: "system@1.11"
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
<<: *build_java
artifacts:
paths:
- "xs2a-standalone-starter/target/xs2a-standalone-starter-exec.jar"
- "consent-management/cms-standalone-service/target/consent-management*jar"
- "aspsp-profile/aspsp-profile-server/target/aspsp-profile*jar"
- "certificate-generator/target/certificate-generator.jar"
- "**/target/*"
- "**/**/target/*"
- ".m2/repository/de/adorsys/psd2/*/*"
name: "${CI_PROJECT_NAME}-${CI_BUILD_REF_NAME#*v}"
expire_in: "1 day"
#-------------------
# Test
#-------------------
Test:IT_Java11:
stage: "Test"
image: maven:3.6.3-jdk-11
except:
- schedules
script:
# - jabba use ${JAVA_VERSION}
- echo "DOCKER_HOST=$DOCKER_HOST"
- cat /sys/fs/cgroup/memory/memory.limit_in_bytes
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp failsafe:integration-test failsafe:verify
variables:
JAVA_VERSION: "system@1.11"
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
TESTCONTAINERS_RYUK_DISABLED: "true"
Test:DOCKER_test_image_build:
stage: "Test"
except:
- schedules
script:
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CNT_MGMNT}:${DOCKER_TAG}" consent-management/cms-standalone-service
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_ASPSP_PROFILE}:${DOCKER_TAG}" aspsp-profile/aspsp-profile-server
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A}:${DOCKER_TAG}" xs2a-standalone-starter
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR}:${DOCKER_TAG}" certificate-generator
variables:
DOCKER_TAG: develop
Test:Javadoc_Java11:
stage: "Test"
except:
- schedules
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 -Dmaven.test.skip=true -Pjavadoc verify javadoc:javadoc
Test:Unit_Tests_XS2A_Java11:
stage: "Test"
except:
- schedules
<<: *java_tests
variables:
JAVA_VERSION: "system@1.11"
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
Test:Sonarcube:
stage: "Test"
needs: []
except:
- schedules
- develop
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 -e --fail-at-end clean install
- mvn -ntp -e sonar:sonar -Dsonar.host.url=${SONAR_HOST} -Dsonar.login=${SONAR_TOKEN}
variables:
TESTCONTAINERS_RYUK_DISABLED: "true"
Test:AsciiDoc:
stage: "Test"
except:
- schedules
image: adorsys/arc42-tools
variables:
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
script:
- make pages
###########
# develop #
###########
Push to DockerHub (develop):
stage: "Package"
only:
- develop
except:
- schedules
variables:
DOCKER_TAG: develop
<<: *build_dockerhub_image
Deploy to Openshift (develop):
stage: "Deploy"
cache: {}
dependencies: []
only:
- develop
except:
- schedules
variables:
GIT_STRATEGY: none
DOCKER_TAG: develop # Dockerhub source tag
OPENSHIFT_NAMESPACE: ${OPENSHIFT_NAMESPACE_ADORSYS_XS2A_DEV} # Openshift target namespace
<<: *deploy_openshift
Notify Slack channel (develop):
image: "bash:4"
stage: "Notification"
cache: {}
only:
- develop
except:
- schedules
variables:
HELM_RELEASE: dev-psd2
ENV_JSON_FILE: scripts/notifications/psd2-dev.json
SLACK_CHANNEL: ${SLACK_PSD2_DEVELOP_CHANNEL}
script:
- apk update && apk add jq curl
- sleep 60
- scripts/notifications/./webhook_slack.sh xs2a cms aspspprofile ledgers
# Build NIGHTLY image and deploy (scheduled) to INTEG
Deploy to Openshift (nightly):
stage: "Deploy"
cache: {}
dependencies: []
only:
- schedules
variables:
GIT_STRATEGY: none
DOCKER_TAG: develop # Dockerhub source tag
OPENSHIFT_NAMESPACE: ${OPENSHIFT_NAMESPACE_ADORSYS_XS2A_INTEG} # Openshift target namespace
<<: *deploy_openshift
Notify Slack channel (Integ):
image: "bash:4"
stage: "Notification"
cache: {}
only:
- schedules
variables:
HELM_RELEASE: integ-psd2
ENV_JSON_FILE: scripts/notifications/psd2-integ.json
SLACK_CHANNEL: ${SLACK_PSD2_INTEG_CHANNEL}
script:
- apk update && apk add jq curl
- sleep 60
- scripts/notifications/./webhook_slack.sh xs2a cms aspspprofile ledgers
# Build MASTER image and deploy to DEMO
Push to DockerHub (master):
stage: "Package"
only:
- master
variables:
DOCKER_TAG: latest
<<: *build_dockerhub_image
# Build RELEASE image and deploy (manual) to DEMO
Push to DockerHub (release):
stage: "Package"
only:
- tags
variables:
DOCKER_TAG: ${CI_COMMIT_TAG}
<<: *build_dockerhub_image