-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
146 lines (133 loc) · 3.04 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
136
137
138
139
140
141
142
143
144
145
stages:
- build
- test_setup
- test
- test_teardown
- report
- docs
- deploy
variables:
REGISTRY_BASE: registry.gitlab.com/engineering-projekt/examibur
JEKYLL_IMAGE: $REGISTRY_BASE:jekyll-$CI_COMMIT_REF_NAME
EXAMIBUR_IMAGE: $REGISTRY_BASE:examibur-$CI_COMMIT_REF_NAME
cache:
paths:
- examibur/build/
- examibur/.gradle/
build_images:
stage: build
image: docker:latest
variables:
DOCKER_DRIVER: overlay
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY_BASE
- docker build -t $JEKYLL_IMAGE -f docker/Dockerfile.jekyll .
- docker push $JEKYLL_IMAGE
build:
image: java:8-jdk
stage: build
script:
- cd examibur/
- ./gradlew assemble
artifacts:
paths:
- examibur/build/libs/
before_test:
image: tmaier/docker-compose
stage: test_setup
variables:
DOCKER_DRIVER: overlay
services:
- docker:dind
script:
- docker-compose rm -f tomcat postgres
- docker-compose up -d --build tomcat postgres
- sleep 15
test:
image: java:8-jdk
stage: test
variables:
UI_TEST_URL: http://tomcat:8080/
DB_HOST: postgres
DB_USER: examibur
DB_PASSWORD: "m4U6ctWpEZE801T"
LOG_LEVEL: INFO
LOG_FILE: examibur.log
script:
- cd examibur && ./gradlew clean test integrationTest
artifacts:
when: always
paths:
- examibur/screenshots/
- examibur/jacoco/jacoco*.exec
after_test:
image: tmaier/docker-compose
stage: test_teardown
variables:
DOCKER_DRIVER: overlay
services:
- docker:dind
script:
- docker-compose stop tomcat postgres
- docker cp examibur_tomcat_1:/var/jacoco/jacocoTomcat.exec examibur/jacoco/jacocoTomcat.exec
- docker-compose kill tomcat postgres
- docker-compose rm -f tomcat postgres
when: always
artifacts:
paths:
- examibur/jacoco/jacocoTomcat.exec
jacoco:
image: java:8-jdk
stage: report
script:
- cd examibur && ls -la jacoco/ && ./gradlew jacocoTestReport
artifacts:
paths:
- examibur/build/reports/jacoco/
report_sonar:
image: java:8-jdk
stage: report
script:
- cd examibur/
- ./gradlew sonarqube -Dsonar.login=$SONARQUBE_TOKEN
artifacts:
paths:
- examibur/build/reports/
only:
- master
generate_pages:
stage: docs
image: $JEKYLL_IMAGE
script:
- cd docs/
- jekyll build -d public
artifacts:
paths:
- docs/public/
examibur_image:
stage: deploy
image: docker:latest
variables:
DOCKER_DRIVER: overlay
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY_BASE
- docker build -t $EXAMIBUR_IMAGE -f docker/Dockerfile.examibur .
- docker push $EXAMIBUR_IMAGE
deploy_staging:
stage: deploy
image: cwt114/alpine-ssh
script:
- mkdir -p ~/.ssh/
- eval `ssh-agent -s`
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
- ssh [email protected]
environment:
name: staging
url: https://examibur-demo.raphael.li/
only:
- master