-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
84 lines (78 loc) · 2.18 KB
/
.gitlab-ci.yml
File metadata and controls
84 lines (78 loc) · 2.18 KB
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
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
MAVEN_CLI_OPTS: "--show-version -s .gitlab-ci_m2.xml"
PRIVATE_REPOSITORY_PULL: repository.dimas-maryanto.com:8086
PRIVATE_REPOSITORY_PUSH: repository.dimas-maryanto.com:8087
stages:
- test
- build
- deploy
- publish
# base image for build java using docker image maven
image:
name: ${PRIVATE_REPOSITORY_PULL}/maven:3.6-jdk-8
test:
stage: test
# Add service PostgreSQL
services:
- name: ${PRIVATE_REPOSITORY_PULL}/postgres:12.3
alias: postgres-db
variables:
POSTGRES_DB: test_data
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user
# hostname for service postgresql is ref to service.alias
DATABASE_HOST: postgres-db
before_script:
- mvn $MAVEN_CLI_OPTS versions:set -DnewVersion=$CI_COMMIT_TAG
script:
- mvn $MAVEN_CLI_OPTS clean test
tags:
- docker
only:
- /-release$/
packaging:
stage: build
before_script:
- mvn $MAVEN_CLI_OPTS versions:set -DnewVersion=$CI_COMMIT_TAG
script:
- mvn $MAVEN_CLI_OPTS clean package -DskipTests
artifacts:
paths:
- target/*.jar
name: $CI_PROJECT_PATH_SLUG-$CI_COMMIT_TAG
tags:
- docker
only:
- /-release$/
docker-publish:
stage: publish
# Enabled to call docker command inside container from docker image maven:3.6-jdk-8
services:
- name: ${PRIVATE_REPOSITORY_PULL}/docker:18.09-dind
# Enabled insecure registry into docker inside docker
entrypoint: ["dockerd-entrypoint.sh"]
# TODO variable `--insecure-registry` cant be inject as variable
command: [
"--insecure-registry=repository.dimas-maryanto.com:8087",
"--insecure-registry=repository.dimas-maryanto.com:8086"
]
alias: dockerd
variables:
# modified file /etc/hosts inside docker container
DOCKER_HOST: tcp://dockerd:2375
DOCKER_DRIVER: overlay2
environment:
name: development
before_script:
- mvn ${MAVEN_CLI_OPTS} versions:set -DnewVersion=$CI_COMMIT_TAG
script:
- mvn ${MAVEN_CLI_OPTS} dockerfile:build dockerfile:push
tags:
- docker
only:
- /-release$/