-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
67 lines (60 loc) · 1.46 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
image: docker:19.03.12
stages:
- test
- visualize
- build
- deploy
variables:
CONTAINER_NAME: api-gateway-service
test:
image: gradle:6.9.0-jdk11
stage: test
script:
- gradle test
artifacts:
paths:
- build/jacoco/jacoco.xml
coverage:
stage: visualize
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.7
script:
- python /opt/cover2cover.py build/jacoco/jacoco.xml $CI_PROJECT_DIR/src/main/java/ > build/cobertura.xml
dependencies:
- test
artifacts:
reports:
cobertura: build/cobertura.xml
build:
image: gradle:6.9.0-jdk11
stage: build
script:
- gradle build -x test
artifacts:
paths:
- build/libs/*.jar
cache:
key: ${CI_COMMIT_REF_SLUG}-${CI_PIPELINE_ID}
policy: push
paths:
- build/libs/*.jar
build-docker-image:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}-${CI_PIPELINE_ID}
policy: pull
paths:
- build/libs/*.jar
script:
- docker login -u $DOCKER_HUB_ID -p $DOCKER_HUB_PASSWORD
- docker build -t $DOCKER_HUB_ID/$IMAGE_NAME .
- docker push $DOCKER_HUB_ID/$IMAGE_NAME
deploy:
stage: deploy
script:
- docker pull $DOCKER_HUB_ID/$IMAGE_NAME
- "{ docker stop $CONTAINER_NAME; docker rm $CONTAINER_NAME; } || true"
- "docker run -d -p $APIGATEWAY_SERVICE_PORT:$APIGATEWAY_SERVICE_PORT \
--network $DOCKER_MESH_NETWORK \
--name $CONTAINER_NAME \
-e CONFIG_SERVER_URL=$CONFIG_SERVER_URL \
$DOCKER_HUB_ID/$IMAGE_NAME"