-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.gitlab-ci.yml
135 lines (120 loc) · 3.36 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
---
# Build JAVA applications using Apache Maven (http://maven.apache.org)
# For docker image tags see https://hub.docker.com/_/maven/
#
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
#
# This template will build and test your projects as well as create the documentation.
#
# * Caches downloaded dependencies and plugins between invocation.
# * Verify but don't deploy merge requests.
# * Deploy built artifacts from master branch only.
# * Shows how to use multiple jobs in test stage for verifying functionality
# with multiple JDKs.
# * Uses site:stage to collect the documentation for multi-module projects.
# * Publishes the documentation for `master` branch.
variables:
MAVEN_CLI_OPTS: "--batch-mode -Ddockerfile.username=gitlab-ci-token -Ddockerfile.password=$CI_BUILD_TOKEN"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
#cache:
# paths:
# - .m2/repository
stages:
- build
- test
- docker
# Run mvn in subfolder
before_script:
- cd server
# This will only validate and compile stuff and run e.g. maven-enforcer-plugin.
# Because some enforcer rules might check dependency convergence and class duplications
# we use `test-compile` here instead of `validate`, so the correct classpath is picked up.
.validate: &validate
stage: build
script:
- 'mvn $MAVEN_CLI_OPTS test-compile install'
artifacts:
paths:
- server/target
# For merge requests do not `deploy` but only run `verify`.
# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
.verify: &verify
stage: test
script:
# TODO: Check from time to time if this is working
#- 'mvn $MAVEN_CLI_OPTS verify site site:site'
- 'mvn $MAVEN_CLI_OPTS verify'
artifacts:
paths:
- server/target/site
tags:
- ILT
# Validate merge requests using JDK8
validate:jdk8:
<<: *validate
image: maven:3.5.4-jdk-8
tags:
- ILT
# Verify merge requests using JDK8
verify:jdk8:
<<: *verify
image: maven:3.5.4-jdk-8
tags:
- ILT
# Validate merge requests using JDK9
validate:jdk9:
<<: *validate
image: maven:3.5.4-jdk-9
tags:
- ILT
# Verify merge requests using JDK9
verify:jdk9:
<<: *verify
image: maven:3.5.4-jdk-9
tags:
- ILT
# Validate merge requests using JDK10
validate:jdk10:
<<: *validate
image: maven:3.5.4-jdk-10
tags:
- ILT
# Verify merge requests using JDK10
verify:jdk10:
<<: *verify
image: maven:3.5.4-jdk-10
tags:
- ILT
.pages:
image: busybox:latest
stage: deploy
script:
# Because Maven appends the artifactId automatically to the staging path if you did define a parent pom,
# you might need to use `mv target/staging/YOUR_ARTIFACT_ID public` instead.
- mv target/site public
dependencies:
- verify:jdk8
artifacts:
paths:
- public
only:
- master
tags:
- ILT
docker:
stage: docker
image: maven:3.5.4-jdk-8
services:
- docker:dind
script:
- curl -sSL https://get.docker.com/ | sh
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- mvn $MAVEN_CLI_OPTS dockerfile:build -Ddocker.image.name="$CI_REGISTRY_IMAGE"
- docker push $CI_REGISTRY_IMAGE
# - mvn $MAVEN_CLI_OPTS dockerfile:push -Ddocker.image.name="$CI_REGISTRY_IMAGE"
dependencies:
- validate:jdk8
tags:
- ILT