-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
98 lines (89 loc) · 2.48 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
image: docker:19.03.12
stages:
- test
- visualize
- build
- package
- deploy
variables:
CONTAINER_NAME: slack-service
JACOCO_CSV_LOCATION: '$CI_PROJECT_DIR/build/jacoco/jacocoCsv'
test:
image: gradle:6.9.0-jdk11
stage: test
script:
- gradle test
- awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' $JACOCO_CSV_LOCATION
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
package-docker-image:
stage: package
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
g238_deploy:
stage: deploy
tags:
- g238
script:
- docker pull $DOCKER_HUB_ID/$IMAGE_NAME
- "{ docker stop $CONTAINER_NAME; docker rm $CONTAINER_NAME; } || true"
- "docker run -d -p $SLACK_SERVICE_PORT:$SLACK_SERVICE_PORT \
--name $CONTAINER_NAME \
-e HOST_IP=$HOST_238_IP \
-e CONFIG_SERVER_URL=$CONFIG_SERVER_URL \
$DOCKER_HUB_ID/$IMAGE_NAME"
g239_deploy:
stage: deploy
tags:
- g239
script:
- docker pull $DOCKER_HUB_ID/$IMAGE_NAME
- "{ docker stop $CONTAINER_NAME; docker rm $CONTAINER_NAME; } || true"
- "docker run -d -p $SLACK_SERVICE_PORT:$SLACK_SERVICE_PORT \
--name $CONTAINER_NAME \
-e HOST_IP=$HOST_239_IP \
-e CONFIG_SERVER_URL=$CONFIG_SERVER_URL \
$DOCKER_HUB_ID/$IMAGE_NAME"
g240_deploy:
stage: deploy
tags:
- g240
script:
- docker pull $DOCKER_HUB_ID/$IMAGE_NAME
- "{ docker stop $CONTAINER_NAME; docker rm $CONTAINER_NAME; } || true"
- "docker run -d -p $SLACK_SERVICE_PORT:$SLACK_SERVICE_PORT \
--name $CONTAINER_NAME \
-e HOST_IP=$HOST_240_IP \
-e CONFIG_SERVER_URL=$CONFIG_SERVER_URL \
$DOCKER_HUB_ID/$IMAGE_NAME"