-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
167 lines (155 loc) · 3.75 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
variables:
ALLOW_QUALITY_GATE_FAILURE: 'false'
default:
id_tokens:
ID_TOKEN:
aud: "https://$VAULT_DOMAIN"
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
stages:
- build
- test
- report
- analyze
- deploy
- rollout
image:
name: maven:3-eclipse-temurin-17
.job-template:
secrets:
ARTIFACTORY_DOMAIN:
vault: Artifactory/domain@Build-Environment
file: false
ARTIFACTORY_USERNAME:
vault: Artifactory/user-write-username@Build-Environment
file: false
ARTIFACTORY_PASSWORD:
vault: Artifactory/user-write-password@Build-Environment
file: false
DEPENDENCY_CHECK_NIST_NVD_API_KEY:
vault: nist-nvd/api-key@Build-Environment
file: false
SONAR_DOMAIN:
vault: Sonar/domain@Build-Environment
file: false
SONAR_TOKEN:
vault: Sonar/token@Build-Environment
file: false
SONATYPE_OSSRH_SIGN_KEY_NAME:
vault: sonatype-ossrh-signing/name@Build-Environment
file: false
SONATYPE_OSSRH_SIGN_KEY_PASSPHRASE:
vault: sonatype-ossrh-signing/passphrase@Build-Environment
file: false
SONATYPE_OSSRH_SIGN_SECRING:
vault: sonatype-ossrh-signing/secring@Build-Environment
file: false
SONATYPE_OSSRH_SIGN_PUBRING:
vault: sonatype-ossrh-signing/pubring@Build-Environment
file: false
SONATYPE_OSSRH_REPO_USERNAME:
vault: sonatype-ossrh-repository/username@Build-Environment
file: false
SONATYPE_OSSRH_REPO_TOKEN:
vault: sonatype-ossrh-repository/token@Build-Environment
file: false
cache:
key: maven-repository
paths:
- .m2/repository
before_script:
- ./configure_maven.sh
build:
extends: .job-template
stage: build
script:
- mvn clean package -DskipTests
artifacts:
paths:
- target
unit test:
extends: .job-template
stage: test
needs:
- job: build
script:
- mvn test
- mvn jacoco:report
- ./print_coverage.sh target/site/jacoco/jacoco.csv
coverage: '/Instructions covered: \d+.\d+%/'
artifacts:
when: always
paths:
- target/surefire-reports
- target/site/jacoco
reports:
junit: target/surefire-reports/TEST-*.xml
dependencies check:
extends: .job-template
stage: report
needs:
- job: build
script:
- mvn dependency-check:check
cache:
- !reference [.job-template, cache]
- key: dependency-check-data
paths:
- target/dependency-check-data
artifacts:
paths:
- target/dependency-check-reports
sonar:
extends: .job-template
stage: analyze
needs:
- job: build
- job: unit test
- job: dependencies check
script:
- mvn -Dsonar.scm.revision=$CI_COMMIT_SHA -Dsonar.branch.name=$CI_COMMIT_REF_NAME sonar:sonar
rules:
- if: $ALLOW_QUALITY_GATE_FAILURE == 'true' || ($CI_COMMIT_TAG == null && $CI_COMMIT_REF_NAME != 'main')
when: on_success
allow_failure: true
- allow_failure: false
deploy development:
extends: .job-template
stage: deploy
needs:
- job: build
- job: sonar
artifacts: false
except:
- tags
script:
- mvn -Pdevelopment deploy -DskipTests
deploy release:
extends: .job-template
stage: deploy
needs:
- job: build
- job: sonar
artifacts: false
only:
- tags
script:
- mvn -Prelease deploy -DskipTests
rollout:
extends: .job-template
stage: rollout
needs:
- job: build
- job: sonar
artifacts: false
only:
- tags
when: manual
script:
- ./configure_gnupg.sh
- mvn -Prollout deploy -DskipTests -Dgpg.keyname=$SONATYPE_OSSRH_SIGN_KEY_NAME -Dgpg.passphrase=$SONATYPE_OSSRH_SIGN_KEY_PASSPHRASE