-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
135 lines (121 loc) · 3.63 KB
/
.gitlab-ci.yml
File metadata and controls
135 lines (121 loc) · 3.63 KB
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
include:
# This includes the GitLab provided dependency scanning jobs
- template: Security/Dependency-Scanning.gitlab-ci.yml
# This includes the GitLab provided SAST jobs.
- template: Security/SAST.gitlab-ci.yml
# This includes the GitLab provided secret detection job
- template: Security/Secret-Detection.gitlab-ci.yml
# Allows the pipeline to be executed as a merge request pipeline and after merges
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
stages:
- validate
- build
- test
- visualize
default:
image: docker.io/library/maven:3-eclipse-temurin-21
cache:
paths:
- .m2/repository/
when: always
artifacts:
# Expire all artifacts already after 36 hours. (Default is around 30 days/4 weeks)
expire_in: 36 hours
variables:
MAVEN_ARGS: "--no-transfer-progress -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dmaven.compiler.useIncrementalCompilation=false"
GIT_STRATEGY: fetch
# Disable all SAST jobs by default, since we manually enable/configure those
SAST_DISABLED: 'true'
############################### JOBS ###############################
Validate:
stage: validate
needs: []
script:
- "mvn $MAVEN_ARGS validate"
Checkstyle:
stage: validate
needs: []
script:
- "mvn $MAVEN_ARGS checkstyle:checkstyle"
- cat target/checkstyle-result.xml | ./scripts/checkstyle_report.sh > checkstyle-report.json
artifacts:
when: always
reports:
codequality:
- checkstyle-report.json
Compile:
stage: build
needs: []
script:
- "mvn $MAVEN_ARGS -DskipTests package"
artifacts:
paths:
- target/scratchlog-*.jar
Unit-Tests:
stage: test
needs: ["Compile"]
variables:
FF_NETWORK_PER_BUILD: "true"
CI_DEBUG_SERVICES: "true"
SPRING_DATASOURCE_URL: "jdbc:mariadb://mariadb:3306/scratchlog"
SPRING_DATASOURCE_USERNAME: scratchlog
SPRING_DATASOURCE_PASSWORD: scratchlog
services:
- name: docker.io/library/mariadb:11
alias: mariadb
variables:
MARIADB_USER: scratchlog
MARIADB_PASSWORD: scratchlog
MARIADB_DATABASE: scratchlog
MARIADB_ROOT_PASSWORD: scratchlog
script:
- "mvn $MAVEN_ARGS test"
after_script:
- mvn $MAVEN_ARGS jacoco:report
# Print summary line, so GitLab can extract code coverage
- cat target/site/jacoco/index.html | grep -o '<tfoot>.*</tfoot>'
coverage: '/Total.*?([0-9]{1,3})%/'
artifacts:
reports:
junit:
- target/surefire-reports/TEST-*.xml
- target/failsafe-reports/TEST-*.xml
coverage_report:
coverage_format: jacoco
path: target/site/jacoco/jacoco.xml
### Analysis (Secret detection)
spotbugs-sast:
stage: test
needs: ["Compile"]
variables:
SAST_ANALYZER_IMAGE_TAG: '6'
SAST_JAVA_VERSION: 21
COMPILE: 'true'
MAVEN_CLI_OPTS: '$MAVEN_ARGS -DskipTests'
# Needs to be set explicitly even if it's set via $MAVEN_ARGS/$MAVEN_CLI_OPTS above, to prevent a fatal spotbugs
# error: 'lstat /root/.m2/repository: no such file or directory'. There exists an upstream issue for a similar error
# https://gitlab.com/gitlab-org/gitlab/-/issues/334854 but the upstream issue is for maven multi-module projects.
MAVEN_REPO_PATH: "$CI_PROJECT_DIR/.m2/repository"
artifacts:
reports:
sast: gl-sast-report.json
rules:
- when: always
gemnasium-maven-dependency_scanning:
stage: test
needs: []
variables:
MAVEN_CLI_OPTS: "$MAVEN_ARGS"
rules:
- when: always
secret_detection:
stage: test
needs: []
cache: []
rules:
- when: always