-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
200 lines (180 loc) · 5.05 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
include:
- project: 'AgileFactory/Witboost.Mesh/witboost.Mesh.CI'
ref: 'main'
file: 'common/witboost.helm.gitlab-ci.yml'
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Jobs/Container-Scanning.gitlab-ci.yml
image: maven:3.9-eclipse-temurin-17
variables:
MAVEN_CLI_OPTS: "-s settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
cache:
paths:
- .m2/repository/
stages:
- setup
- compile
- test
- coverage
- package
- publish
setup:
stage: setup
extends: .witboost.helm.base-job
cache: []
before_script: []
script:
- !reference [.witboost.helm.clone-scripts, script]
- !reference [.witboost.helm.get-version, script]
- echo "VERSION=${VERSION}" >> vars.env
- echo "PROVISIONER_VERSION=${VERSION}" >> vars.env
artifacts:
reports:
dotenv: vars.env
sast:
stage: setup
cache: []
artifacts:
paths:
- gl-sast-report.json
reports:
sast: gl-sast-report.json
secret_detection:
stage: setup
cache: []
artifacts:
paths:
- gl-secret-detection-report.json
reports:
secret_detection: gl-secret-detection-report.json
fail_on_detection:
needs:
- semgrep-sast
- secret_detection
before_script:
- apt update -y && apt -y install jq
script:
- ls -a
- jq '.vulnerabilities[] | .severity' gl-sast-report.json | grep 'High\|Critical' && echo 'Vulnerabilities found in gl-sast-report.json' && exit 1 || true;
- jq '.vulnerabilities[] | .severity' gl-secret-detection-report.json | grep 'High\|Critical' && echo 'Vulnerabilities found in gl-secret-detection-report.json' && exit 1 || true;
- echo 'No serious vulnerabilities found.'
rules:
- if: $CI_COMMIT_BRANCH
exists:
- '**/*.py'
- '**/*.js'
- '**/*.jsx'
- '**/*.ts'
- '**/*.tsx'
- '**/*.c'
- '**/*.go'
- '**/*.java'
- '**/*.cs'
- '**/*.html'
- '**/*.scala'
- '**/*.sc'
vulnerability_analysis:
stage: compile
before_script:
- mvn --version
script:
- mvn -DskipTests=true package org.owasp:dependency-check-maven:check
artifacts:
when: always
paths:
- report/target/dependency-check-report.html
license_check:
stage: compile
before_script:
- mvn --version
script:
- mvn -DskipTests=true package licensescan:audit
artifacts:
when: always
paths:
- collibra-data-catalog-plugin-server/target/license-scan-results/index.html
- collibra-data-catalog-plugin-server/target/license-scan-results/license-scan-report.json
linter:
stage: compile
before_script:
- mvn --version
script:
- mvn checkstyle:check
- mvn spotless:check
compile:
stage: compile
script:
- mvn $MAVEN_CLI_OPTS compile
test-jdk17:
stage: test
script:
- mvn $MAVEN_CLI_OPTS org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report-aggregate
- cat report/target/site/jacoco-aggregate/index.html | grep -o '<tfoot>.*</tfoot>'
coverage: '/Total.*?([0-9]{1,3})%/'
artifacts:
when: always
paths:
- report/target/site/jacoco-aggregate/jacoco.xml
coverage-jdk17:
stage: test
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9
script:
- jacoco_paths=`find * -path "**/src/main/java" -type d | sed -e 's@^@'"$CI_PROJECT_DIR"'/@'`
- python /opt/cover2cover.py report/target/site/jacoco-aggregate/jacoco.xml $jacoco_paths > report/target/site/cobertura.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: report/target/site/cobertura.xml
needs:
- test-jdk17
package:
stage: package
script:
- mvn $MAVEN_CLI_OPTS package spring-boot:repackage
artifacts:
paths:
- collibra-data-catalog-plugin-server/target/*.jar
publish:
stage: publish
script:
- mvn deploy -s ci_settings.xml
docker_build:
stage: publish
image: docker:23.0.0
services:
- docker:23.0.0-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:$VERSION .
- docker push $CI_REGISTRY_IMAGE:$VERSION
helm_package:
stage: publish
extends: .witboost.helm.deploy
needs:
- docker_build
container_scanning:
stage: publish
variables:
GIT_STRATEGY: fetch
CS_DOCKERFILE_PATH: .
CS_IMAGE: $CI_REGISTRY_IMAGE:$VERSION
needs:
- setup
- docker_build
dependencies:
- setup
check_vulnerabilities_analysis:
stage: publish
before_script:
- apt update -y && apt -y install jq
script:
- ls -a
- jq '.vulnerabilities[] | .severity' gl-container-scanning-report.json | grep 'High\|Critical' && echo 'Vulnerabilities found in gl-container-scanning-report.json' && exit 1|| true;
- jq '.vulnerabilities[] | .severity' gl-dependency-scanning-report.json | grep 'High\|Critical' && echo 'Vulnerabilities found in gl-dependency-scanning-report.json' && exit 1|| true;
- echo 'No serious vulnerabilities found.'
needs:
- container_scanning
rules:
- if: $CI_COMMIT_BRANCH