-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
345 lines (317 loc) · 9.78 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
# Copyright (c) 2023 WPS - Workplace Solutions GmbH
#
# Licensed under the EUPL, Version 1.2 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
#
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at:
#
# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
#
# Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the Licence for the specific language governing permissions and limitations under the Licence.
stages:
- prepare
- build_test
- package
- release
- deploy
variables:
# Docker host for testcontainer:
DOCKER_HOST: "tcp:https://docker:2375"
DOCKER_TLS_CERTDIR: ""
BACKEND_IMAGE_NAME: "$CI_REGISTRY_IMAGE/radvis-backend"
GEOSERVER_IMAGE_NAME: "$CI_REGISTRY_IMAGE/radvis-geoserver"
GEOSERVER_BASE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/geoserver-base"
GEOSERVER_BASE_IMAGE_VERSION: "2.25.3"
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
services:
- docker:19.03.0-dind
.docker_job:
image: docker:stable
before_script:
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
install_dependencies:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/maven-chrome-runner
stage: prepare
except:
# Tag-Pipelines müssen nicht erneut das Dependencies runterladen, da der Cache durch den zugehörigen Branch schon existiert
- tags
script:
- set -o pipefail
- mvn $MAVEN_CLI_OPTS compile -DskipTests -Png-install
artifacts:
paths:
- distribution/target
cache:
key:
files:
- backend/pom.xml
- frontend/radvis/package-lock.json
paths:
- .m2/repository
- frontend/radvis/.npm
build:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/maven-chrome-runner
stage: build_test
needs:
- install_dependencies
except:
# Tag-Pipelines müssen nicht erneut das Artefakt bauen, da es vom zugehörigen Branch schon existiert
- tags
script:
- set -o pipefail
- mvn $MAVEN_CLI_OPTS package -DskipTests -Png-install,ng-build,ng-version
artifacts:
paths:
- distribution/target
cache:
key:
files:
- backend/pom.xml
- frontend/radvis/package-lock.json
policy: pull
paths:
- .m2/repository
- frontend/radvis/.npm
backend_integration_tests:
image: maven:3.9-eclipse-temurin-17-focal
stage: build_test
needs:
- install_dependencies
# Starte den Job 7-mal nebeneinander
# jeder Job ist von 1 bis 7 durchnummeriert und die Nummer ist durch CI_NODE_INDEX nutzbar
parallel: 7
except:
- tags
variables:
SPRING_LOG_LEVEL: "WARN"
HIBERNATE_LOG_LEVEL: "WARN"
script:
- set -o pipefail
# Bauen und Testen und das Ergebnis in log datei mitschreiben für die anschließende Analyse
# mit grep wird output von liquibase auf stdout gefiltert. (No logger? urgh! siehe https://github.com/liquibase/liquibase/issues/2396)
# Keine Ausgabe des ablaufenden changesets
- mvn $MAVEN_CLI_OPTS -DskipSurefire=true -Dtest.group="group$CI_NODE_INDEX" -pl backend verify | grep -v "^Running\sChangeset"
cache:
key:
files:
- backend/pom.xml
- frontend/radvis/package-lock.json
policy: pull
paths:
- .m2/repository
- frontend/radvis/.npm
backend_unit_tests:
image: maven:3.9-eclipse-temurin-17-focal
needs:
- install_dependencies
stage: build_test
except:
- tags
script:
- set -o pipefail
- mvn $MAVEN_CLI_OPTS -T 1C -pl backend test
cache:
key:
files:
- backend/pom.xml
- frontend/radvis/package-lock.json
policy: pull
paths:
- .m2/repository
- frontend/radvis/.npm
frontend_tests:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/maven-chrome-runner
stage: build_test
needs:
- install_dependencies
except:
- tags
script:
- set -o pipefail
- mvn $MAVEN_CLI_OPTS -DskipTests -pl frontend compile -Png-install
- mvn $MAVEN_CLI_OPTS -pl frontend test
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: frontend/radvis/coverage/radvis/cobertura-coverage.xml
expire_in: 1 week
cache:
key:
files:
- backend/pom.xml
- frontend/radvis/package-lock.json
policy: pull
paths:
- .m2/repository
- frontend/radvis/.npm
frontend_lint:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/maven-chrome-runner
stage: build_test
needs:
- install_dependencies
except:
- tags
script:
- set -o pipefail
- mvn $MAVEN_CLI_OPTS -DskipTests -pl frontend compile -Png-install,ng-lint
cache:
key:
files:
- backend/pom.xml
- frontend/radvis/package-lock.json
policy: pull
paths:
- .m2/repository
- frontend/radvis/.npm
package_docker_backend_image:
stage: package
needs:
- backend_unit_tests
- backend_integration_tests
- frontend_tests
- frontend_lint
- build
extends: .docker_job
except:
- tags
script:
- set -eoux pipefail
- docker build -t $BACKEND_IMAGE_NAME:$CI_COMMIT_SHA ./distribution
- docker push $BACKEND_IMAGE_NAME:$CI_COMMIT_SHA
package_geoserver_base_image:
stage: package
extends: .docker_job
retry:
max: 2
when: job_execution_timeout
script:
- if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $GEOSERVER_BASE_IMAGE_NAME:$GEOSERVER_BASE_IMAGE_VERSION >> /dev/null ; then exit ; fi
- docker build -t $GEOSERVER_BASE_IMAGE_NAME:$CI_COMMIT_SHA --build-arg GEOSERVER_BASE_IMAGE_VERSION=$GEOSERVER_BASE_IMAGE_VERSION ./infrastruktur/geoserver/geoserver_base
- docker push $GEOSERVER_BASE_IMAGE_NAME:$CI_COMMIT_SHA
- docker tag $GEOSERVER_BASE_IMAGE_NAME:$CI_COMMIT_SHA $GEOSERVER_BASE_IMAGE_NAME:$GEOSERVER_BASE_IMAGE_VERSION
- docker push $GEOSERVER_BASE_IMAGE_NAME:$GEOSERVER_BASE_IMAGE_VERSION
package_geoserver_radvis_image:
stage: package
extends: .docker_job
needs:
- job: package_geoserver_base_image
optional: true
script:
- docker build -t $GEOSERVER_IMAGE_NAME:$CI_COMMIT_SHA --build-arg GEOSERVER_BASE_IMAGE_NAME=$GEOSERVER_BASE_IMAGE_NAME --build-arg GEOSERVER_BASE_IMAGE_VERSION=$GEOSERVER_BASE_IMAGE_VERSION ./infrastruktur/geoserver/
- docker push $GEOSERVER_IMAGE_NAME:$CI_COMMIT_SHA
.tag_docker_images:
stage: deploy
extends: .docker_job
script:
- docker pull $BACKEND_IMAGE_NAME:$CI_COMMIT_SHA
- docker pull $GEOSERVER_IMAGE_NAME:$CI_COMMIT_SHA
- docker tag $BACKEND_IMAGE_NAME:$CI_COMMIT_SHA $BACKEND_IMAGE_NAME:$TAG
- docker tag $GEOSERVER_IMAGE_NAME:$CI_COMMIT_SHA $GEOSERVER_IMAGE_NAME:$TAG
- docker push $BACKEND_IMAGE_NAME:$TAG
- docker push $GEOSERVER_IMAGE_NAME:$TAG
tag_latest_docker_image:
extends: .tag_docker_images
only:
- master
variables:
TAG: latest
tag_release_docker_image:
extends: .tag_docker_images
only:
- tags
variables:
TAG: $CI_COMMIT_REF_NAME
.deploy_job:
stage: deploy
when: manual
variables:
PROPERTY_KEY: VERSION_TAG
deploy_dev:
extends: .deploy_job
variables:
PROPERTY_VALUE: $CI_COMMIT_SHA
ENV_URL: https://radvis-dev.landbw.de
trigger:
project: radvis/infrastruktur-bitbw
branch: dev
deploy_vertrieb:
extends: .deploy_job
variables:
PROPERTY_VALUE: $CI_COMMIT_SHA
ENV_URL: https://radvis-demo.wps.de
trigger:
project: radvis/infrastruktur-bitbw
branch: vertrieb
deploy_dev_scheduled:
extends: deploy_dev
when: always
only:
variables:
- $DEPLOY_DEV
deploy_test:
extends: .deploy_job
only:
- tags
variables:
PROPERTY_VALUE: $CI_COMMIT_REF_NAME
ENV_URL: https://radvis-test.landbw.de
trigger:
project: radvis/infrastruktur-bitbw
branch: test
deploy_prod:
extends: .deploy_job
only:
- tags
variables:
PROPERTY_VALUE: $CI_COMMIT_REF_NAME
ENV_URL: https://radvis.landbw.de
trigger:
project: radvis/infrastruktur-bitbw
branch: prod
update-maven-dependencies:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/maven-dependency-updater
stage: build_test
needs:
- install_dependencies
only:
variables:
- $UPDATE_DEPS
variables:
COMMAND: "mvn versions:use-latest-versions && mvn versions:update-parent"
script:
- export BRANCH_NAME="maven-dependencies-update_$(date -I)"
- export TARGET_BRANCH_NAME="$CI_COMMIT_BRANCH"
- export COMMIT_MESSAGE="Update maven dependencies ($(date -I))"
- run-update-and-create-mr.sh
release-patch:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/gitlab-release-it-runner
stage: release
when: manual
only:
- master
- /^release-.*$/
variables:
GITLAB_TOKEN: $GITLAB_ACCESS_TOKEN
script:
- create-tag
release:
extends: release-patch
variables:
DEFAULT_INCREASE_VERSION: minor
gitlab-release:
image: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/gitlab-release-it-runner
stage: release
only:
- tags
variables:
GITLAB_TOKEN: $GITLAB_ACCESS_TOKEN
script:
- create-release