-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy path.gitlab-ci.yml
331 lines (299 loc) · 10.4 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
---
# 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
- "Release" # release
- "Clone to github"
# ------------------------------------------------------------------
# variables
# ------------------------------------------------------------------
variables:
DOCKER_IMAGE_NAME_CMS_MANAGEMENT: "xs2a-consent-management"
DOCKER_IMAGE_NAME_ASPSP_PROFILE: "xs2a-aspsp-profile"
DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR: "xs2a-certificate-generator"
###########################
# 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}
- 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
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp -DskipITs --fail-at-end clean install -q
.push_dockerhub_images_private: &push_dockerhub_images_private
script:
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CMS_MANAGEMENT}:${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_CERTIFICATE_GENERATOR}:${DOCKER_TAG}" certificate-generator
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CMS_MANAGEMENT}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_ASPSP_PROFILE}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_CERTIFICATE_GENERATOR}:${DOCKER_TAG}"
- docker logout
.release_java_private: &release_java_private
stage: "Release"
script:
- jabba use $BUILD_JAVA_VERSION
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp --settings scripts/mvn-release-settings.xml -Pgitlab-maven -DskipTests -U deploy
cache:
key: "Java_${CI_COMMIT_REF_SLUG}"
paths:
- /builds/adorsys/xs2a/xs2a-conector-examples/.m2/repository
.sync_changes_github: &sync_changes_github
image: alpine/git
script:
- git config --global user.name "$GITHUB_USERNAME"
- git remote add github https://[email protected]/$GITHUB_REPOSITORY.git
- for branch in $(git branch -r | grep -E "origin/.*(release-${GITHUB_PROJECT_CLONE_VERSION}.*|support-${GITHUB_PROJECT_CLONE_VERSION}.x).*"); do
branch=${branch#origin/};
git checkout $branch;
git push github $branch;
done
# ------------------------------------------------------------------
# jobs
# ------------------------------------------------------------------
#-------------------------------------------------------------------
# lint
#-------------------------------------------------------------------
Lint (Docker compose):
image: maven:3.6-jdk-11-slim
stage: "Lint"
except:
- schedules
- support-14.x
- master-14.x
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:stable-slim
stage: "Lint"
except:
- schedules
- support-14.x
- master-14.x
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 (YAML, JSON, XML):
image: debian:stable-slim
stage: "Lint"
except:
- schedules
- support-14.x
- master-14.x
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 (PMD CPD):
image: maven:3.6-jdk-11-slim
stage: "Lint"
except:
- schedules
- support-14.x
- master-14.x
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 (dockerfiles):
image: docker
stage: "Lint"
services:
- docker:dind
tags:
- aws
except:
- schedules
- support-14.x
- master-14.x
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
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:
stage: "Compile"
except:
- schedules
variables:
JAVA_VERSION: "[email protected]"
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):
stage: "Test"
image: maven:3.6.3-jdk-11
services:
- docker:dind
tags:
- aws
except:
- schedules
script:
# - jabba use ${JAVA_VERSION}
- echo "DOCKER_HOST=${DOCKER_HOST}"
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp failsafe:integration-test failsafe:verify
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
JAVA_VERSION: "[email protected]"
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
TESTCONTAINERS_RYUK_DISABLED: "true"
Test (Javadoc):
stage: "Test"
except:
- schedules
variables:
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
JAVA_VERSION: "[email protected]"
script:
- jabba use ${JAVA_VERSION}
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -ntp -Dmaven.test.skip=true -Pjavadoc verify javadoc:javadoc
Test (Unit Tests):
stage: "Test"
except:
- schedules
<<: *java_tests
variables:
JAVA_VERSION: "[email protected]"
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
Test (ASCII Doc):
stage: "Test"
except:
- schedules
image: adorsys/arc42-tools
variables:
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
script:
- make pages
Build and push images to private repo (support-14.x):
stage: "Package"
services:
- docker:dind
tags:
- aws
except:
- schedules
only:
- support-14.x
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
DOCKER_TAG: support14x
DOCKERHUB_REGISTRY: gitlab-registry.adorsys.de
DOCKERHUB_NAMESPACE: "adorsys/xs2a/aspsp-xs2a"
<<: *push_dockerhub_images_private
Build and push images to private repo (Tags):
stage: "Package"
services:
- docker:dind
tags:
- aws
only:
- tags
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
DOCKER_TAG: $CI_COMMIT_TAG
DOCKERHUB_REGISTRY: gitlab-registry.adorsys.de
DOCKERHUB_NAMESPACE: "adorsys/xs2a/aspsp-xs2a"
<<: *push_dockerhub_images_private
Release snapshot artifacts (support-14.x):
stage: "Release"
only:
- support-14.x
except:
- schedules
cache: {}
variables:
BUILD_JAVA_VERSION: [email protected]
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
<<: *release_java_private
Release snapshot artifacts (tags):
stage: "Release"
only:
- tags
except:
- schedules
cache: {}
variables:
BUILD_JAVA_VERSION: [email protected]
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
<<: *release_java_private
Clone to github:
stage: "Clone to github"
image: alpine/git:latest
dependencies: []
only:
- support-14.x
- /^release-14\..*/
except:
- schedules
variables:
GITHUB_REPOSITORY: adorsys/xs2a
GITHUB_PROJECT_CLONE_VERSION: "14"
<<: *sync_changes_github