forked from TIBHannover/oersi-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
66 lines (56 loc) · 1.68 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
image: maven:3-openjdk-17
# DinD service is required for Testcontainers
services:
- name: docker:dind
# explicitly disable tls to avoid docker startup interruption
command: ["--tls=false"]
variables:
MAVEN_CLI_OPTS: "--batch-mode -s ci_settings.xml"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# Instruct Testcontainers to use the daemon of DinD, use port 2735 for non-tls connections.
DOCKER_HOST: "tcp://docker:2375"
# Instruct Docker not to start over TLS.
DOCKER_TLS_CERTDIR: ""
# Improve performance with overlayfs.
DOCKER_DRIVER: overlay2
cache:
paths:
- .m2/repository/
- target/
include:
- local: '.gitlab-ci-sonar.yml'
build:
stage: build
script:
- mvn $MAVEN_CLI_OPTS clean compile
test:
stage: test
script:
- mvn $MAVEN_CLI_OPTS test
.deploy_job:
stage: deploy
before_script:
- "PROJECTVERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)"
- "TIMESTAMP=$(date +'%Y%m%d%H%M%S')"
- '[[ "$PROJECTVERSION" == *-SNAPSHOT ]] && PROJECTVERSION=${PROJECTVERSION::-9}-${TIMESTAMP} && mvn versions:set -DnewVersion=$PROJECTVERSION'
- echo VERSION=${PROJECTVERSION} > build.info
- echo BUILDNUMBER=${CI_JOB_ID} >> build.info
- echo COMMIT_SHA=${CI_COMMIT_SHORT_SHA} >> build.info
- echo TIMESTAMP=${TIMESTAMP} >> build.info
- cat build.info
- mv build.info src/main/resources
deploy branch:
extends: .deploy_job
script:
- "mvn $MAVEN_CLI_OPTS package -Dmaven.test.skip"
artifacts:
paths:
- target/*.war
only:
- branches
deploy release:
extends: .deploy_job
script:
- "mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip"
only:
- tags