-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
109 lines (94 loc) · 3.54 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
stages:
- build
- test
- package
- deploy
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: ""
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true -Dmaven.compiler.staleMillis=3600000 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
include:
- template: Security/Secret-Detection.gitlab-ci.yml
# - template: Code-Quality.gitlab-ci.yml
#code_quality:
# artifacts:
# paths: [gl-code-quality-report.json]
workflow:
rules:
# run a merge request pipeline if that makes sense
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# don't run a branch pipeline on commits if we'll run a merge request pipeline
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
# do run a branch pipeline for other commits
- if: '$CI_COMMIT_BRANCH'
# rules:
# - changes:
# - src/**/*
# - pom.xml
# Use Maven 3.8.4 on OpenJDK 17 with 'slim' Ubuntu
image: maven:3.8.4-openjdk-17-slim
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
key: "$CI_JOB_NAME"
# run mvn compile to build the project
build:
stage: build
script:
- 'mvn $MAVEN_CLI_OPTS compile'
artifacts:
paths:
- target/
# run mvn verify to compile and test the project
test:
stage: test
script:
- 'mvn $MAVEN_CLI_OPTS test'
- 'if [ -f target/site/jacoco/index.html ]; then sed -E -e "s;^.*Total[^%]*>([0-9]+%)<.*$;Total Coverage: \\1\\n;g" target/site/jacoco/index.html; fi'
artifacts:
reports:
junit: target/surefire-reports/TEST-*.xml
paths:
- target/
coverage: '/Total.*?([0-9]{1,3})%/'
dependencies:
- build
# run mvn package to build jar files
# 'verify' does 'package', then runs integration tests
package:
stage: package
script:
- 'mvn $MAVEN_CLI_OPTS verify'
artifacts:
paths:
- target/*.jar
dependencies:
- test
# To deploy packages from CI, create a ci_settings.xml file
# For deploying packages to GitLab's Maven Repository: See https://docs.gitlab.com/ee/user/packages/maven_repository/index.html#create-maven-packages-with-gitlab-cicd for more details.
# For `master` branch run `mvn deploy` automatically.
deploy:
stage: deploy
script:
- if [ ! -f ci_settings.xml ];
then echo "CI settings missing\! If deploying to GitLab Maven Repository, please see https://docs.gitlab.com/ee/user/packages/maven_repository/index.html#create-maven-packages-with-gitlab-cicd for instructions.";
else
mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml
fi
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists:
- ci_settings.xml
dependencies:
- package
check updates:
stage: test
script:
- mvn versions:display-plugin-updates versions:display-property-updates versions:display-dependency-updates -D allowMajorUpdates=false