-
Notifications
You must be signed in to change notification settings - Fork 17
/
.gitlab-ci.yml
51 lines (46 loc) · 1.34 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
variables:
PUBLIC_TAG: 'strm/tasker'
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=cache/m2/repository"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
cache:
paths:
- cache/m2/repository
# keep cache across branch
key: "$CI_BUILD_REF_NAME"
stages:
- build
- test
- package
build-backend:
stage: build
script:
- "mvn clean compile package -Dmaven.test.skip=true $MAVEN_CLI_OPTS"
artifacts:
paths:
- target/tasker-0.0.1-SNAPSHOT.jar
tags:
- docker
test-backend:
stage: test
dependencies:
- build-backend
script:
- "mvn test $MAVEN_CLI_OPTS"
- "cat target/site/jacoco/index.html"
tags:
- docker
package-docker:
stage: package
dependencies:
- build-backend
- test-backend
script:
- export IMAGE_TAG=$(echo -en $CI_BUILD_REF_NAME | tr -c '[:alnum:]_.-' '-' | sed 's/master/latest/g')
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" -f Dockerfile.gitlab .
- docker push "$CI_REGISTRY_IMAGE:$IMAGE_TAG"
- docker tag "$CI_REGISTRY_IMAGE:$IMAGE_TAG" "$PUBLIC_TAG"
tags:
- docker