-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
110 lines (102 loc) · 2.07 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
stages:
- build
- test
- analyze
- package
- deploy
image: maven:3.9.7-eclipse-temurin-21
variables:
maven_packages_cache: ".m2/repository"
MAVEN_OPTS: "-Dmaven.repo.local=./$maven_packages_cache"
sonar_project: "ConnectFour"
sonar_url: "http://sonarqube:9000"
sonar_login: "sqp_988f737b755e111b3dbb071901c3b11c85dd3b22"
build:
stage: build
tags:
- docker
cache:
paths:
- $maven_packages_cache
artifacts:
name: $CI_JOB_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
expire_in: 1 week
paths:
- "target/*"
script:
- mvn compile
test:
stage: test
tags:
- docker
dependencies:
- build
cache:
paths:
- $maven_packages_cache
artifacts:
name: $CI_JOB_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
expire_in: 1 week
paths:
- "target/surefire-reports/*"
- "target/site/jacoco/*"
script:
- mvn test
analyze:
stage: analyze
tags:
- docker
dependencies:
- build
- test
cache:
paths:
- $maven_packages_cache
script:
- mvn sonar:sonar -Dsonar.projectKey=$sonar_project -Dsonar.host.url=$sonar_url -Dsonar.login=$sonar_login -Dsonar.qualitygate.wait=true
allow_failure: true
package:
stage: package
tags:
- docker
dependencies:
- build
cache:
paths:
- $maven_packages_cache
artifacts:
name: $CI_JOB_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
expire_in: 1 week
paths:
- "target/*.war"
script:
- mvn package
deploy_test:
stage: deploy
tags:
- shell
dependencies:
- package
environment:
name: test
action: start
url: http://localhost:8080/ConnectFour
on_stop: stop_test
when:
manual
script:
- docker rm --force connectfour
- docker image rm --force connectfour
- docker build . -t connectfour
- docker run -d --rm --name connectfour -p 8080:8080 connectfour
stop_test:
stage: deploy
tags:
- shell
environment:
name: test
action: stop
when: manual
script:
- docker rm --force connectfour
- docker image rm --force connectfour