-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.gitlab-ci.yml
302 lines (270 loc) · 9.32 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
---
# 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
- "Release" # release
- "Clone to github"
# ------------------------------------------------------------------
# variables
# ------------------------------------------------------------------
variables:
###########################
# Docker images variables #
###########################
DOCKER_IMAGE_NAME_XS2A_CONNECTOR: "xs2a-connector-examples"
DOCKER_IMAGE_NAME_XS2A_CONNECTOR_EMBEDDED: "xs2a-connector-embedded"
###########################
# Build variables #
###########################
JAVA_TOOL_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:MaxRAM=3G -XX:MaxRAMFraction=3"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# ------------------------------------------------------------------
# reusable yaml anchors
# ------------------------------------------------------------------
.build_and_push_dockerhub_images_private: &build_and_push_dockerhub_images_private
script:
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_CONNECTOR}:${DOCKER_TAG}" gateway-app
- docker build -t "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_CONNECTOR_EMBEDDED}:${DOCKER_TAG}" gateway-app-embedded
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_CONNECTOR}:${DOCKER_TAG}"
- docker push "${DOCKERHUB_REGISTRY}/${DOCKERHUB_NAMESPACE}/${DOCKER_IMAGE_NAME_XS2A_CONNECTOR_EMBEDDED}:${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
dependencies: []
script:
- git config --global user.name "$GITHUB_USERNAME"
- git remote add github https://[email protected]/$GITHUB_REPOSITORY.git #Token expires on Sat, 11.05.2024
- 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 --force;
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):
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"
- mvn --settings scripts/mvn-release-settings.xml -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
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
except:
- schedules
- support-14.x
- master-14.x
script:
- echo "Run Xs2a connector dockerfile checks"
- docker run --rm -i hadolint/hadolint < ./gateway-app/Dockerfile
- docker run --rm -i hadolint/hadolint < ./gateway-app-embedded/Dockerfile
#-------------------------------------------------------------------
# Compile
#-------------------------------------------------------------------
Build (XS2A Connector):
stage: "Compile"
script:
- jabba use "[email protected]"
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn -DskipITs -DskipTests --settings scripts/mvn-release-settings.xml -Dci.build.number=Build\:${CI_PIPELINE_ID} clean install
artifacts:
paths:
- "gateway-app/target/gateway-app*jar"
- "gateway-app-embedded/target/gateway-app*jar"
- "ledgers-rest-client/target/ledgers-rest-client*jar"
- "xs2a-connector/target/xs2a-connector*jar"
- "**/target/*"
- "**/**/target/*"
- ".m2/repository/de/adorsys/ledgers/*/*"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}"
expire_in: "10 day"
#-------------------
# Test
#-------------------
Test (Javadoc):
stage: "Test"
script:
- jabba use "[email protected]"
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn --settings scripts/mvn-release-settings.xml -Dmaven.test.skip=true package javadoc:javadoc
artifacts:
paths:
- "**/target/site/*"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}-javadoc"
expire_in: "10 day"
Test (Unit Tests):
stage: "Test"
script:
- jabba use "[email protected]"
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn --settings scripts/mvn-release-settings.xml -DskipITs --fail-at-end clean install
artifacts:
paths:
- "**/target/surefire-reports/*"
name: "$CI_PROJECT_NAME-${CI_BUILD_REF_NAME#*v}-*"
expire_in: "10 day"
Test (IT):
stage: "Test"
script:
- jabba use "[email protected]"
- java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram"
- mvn --settings scripts/mvn-release-settings.xml -ntp failsafe:integration-test failsafe:verify
variables:
JAVA_TOOL_OPTIONS: "-Djavax.net.ssl.trustStorePassword=changeit -XX:MaxRAM=3G"
################
# Package
################
Build and push images to private repo (support14x):
stage: "Package"
# except:
# - schedules
only:
- support-14.x
services:
- docker:dind
tags:
- aws
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/xs2a-connector-examples"
<<: *build_and_push_dockerhub_images_private
Build and push images to private repo (tags):
stage: "Package"
only:
- tags
services:
- docker:dind
tags:
- aws
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/xs2a-connector-examples"
<<: *build_and_push_dockerhub_images_private
###########
# Release #
###########
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
only:
- support-14.x
- /^release-14\..*/
except:
- schedules
variables:
GITHUB_REPOSITORY: adorsys/xs2a-connector-examples
GITHUB_PROJECT_CLONE_VERSION: "14"
<<: *sync_changes_github