-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
153 lines (137 loc) · 3.14 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
146
147
148
149
150
151
152
153
default:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/maven:3-openjdk-17
tags:
- docker
cache:
paths:
- .m2/repository
- .sonar
stages:
- compile
- test
- post_process
- deploy
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
SONAR_USER_HOME: "$CI_PROJECT_DIR/.sonar"
compile_source:
stage: compile
script:
- mvn clean process-classes -U
artifacts:
name: compiled_sources
expire_in: 1 hour
paths:
- target/*
compile_test:
stage: compile
script:
- mvn process-test-classes
needs:
- compile_source
artifacts:
name: compiled_sources_and_tests
expire_in: 1 hour
paths:
- target/*
.test_job:
stage: test
needs:
- compile_test
test_unit:
extends: .test_job
script:
- mvn package
artifacts:
name: unit_artifacts
reports:
junit:
- "target/surefire-reports/TEST-*.xml"
expire_in: 1 hour
paths:
- target/jacoco.exec
- "target/surefire-reports/TEST-*.xml"
test_integration:
extends: .test_job
script:
- mvn install -Dsurefire.skip
artifacts:
name: integration_artifacts
reports:
junit:
- "target/failsafe-reports/TEST-*.xml"
expire_in: 1 hour
paths:
- "target/failsafe-reports/TEST-*.xml"
.post-processing_job:
stage: post_process
allow_failure: true
maven_site:
extends: .post-processing_job
coverage: '/Total.*?([0-9]{1,3})%/'
script:
- mvn site
- grep -Po "Total.*?([0-9]{1,3})%" target/site/jacoco/index.html
needs:
- compile_test
- test_unit
- test_integration
environment:
name: maven_site/$CI_COMMIT_REF_NAME
url: $CI_PROJECT_URL/-/jobs/artifacts/$CI_COMMIT_REF_NAME/file/target/site/index.html?job=maven_site
auto_stop_in: 30 days
artifacts:
name: site_artifacts
expose_as: "Maven project site"
expire_in: 1 hour
paths:
- target/site/
visualize_coverage:
extends: .post-processing_job
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.7
script:
- python /opt/cover2cover.py target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/src/main/java/ > target/site/cobertura.xml
needs:
- maven_site
artifacts:
reports:
cobertura: target/site/cobertura.xml
sonarqube:
extends: .post-processing_job
when: always
needs:
- test_unit
- test_integration
- compile_test
- maven_site
script:
- mvn sonar:sonar -Dsonar.host.url=$SONARQUBE_URL -Dsonar.login=$SONARQUBE_TOKEN -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY -Dsonar.projectName="$SONARQUBE_PROJECT_NAME"
.deploy_job:
stage: deploy
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
needs:
- compile_source
- compile_test
- test_unit
- test_integration
pages:
extends: .deploy_job
script:
- mv -T target/site public
needs:
- maven_site
artifacts:
name: page_artifacts
expire_in: 1 hour
paths:
- public
deploy_maven_package:
extends: .deploy_job
script:
- mvn deploy -s ci_settings.xml -Dsurefire.skip -Dfailsafe.skip
deploy_jib_image:
extends: .deploy_job
script:
- mvn -s ci_settings.xml jib:build