-
Notifications
You must be signed in to change notification settings - Fork 6
/
.gitlab-ci.yml
88 lines (80 loc) · 2.46 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
image: maven:3-eclipse-temurin-17
stages:
- build
- test
- deploy
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
cache: &cache
paths:
- .m2/repository/
- target/
build:
stage: build
script:
- mvn compile
test:
stage: test
coverage: '/Total.*?([0-9]{1,3})%./'
script:
- mvn test checkstyle:checkstyle
- mvn jacoco:report
- cat target/site/jacoco/index.html | grep -o '<tfoot>.*</tfoot>'
- |
file="";
first=1;
output="checkstyle-report.json"
path="$(pwd)";
echo "[" > "$output";
tail -n +3 target/checkstyle-result.xml | while read p; do
if echo "$p" | grep -q "<file name.*" ; then
file=$(expr "$p" : '<file name=\"\(.*\)\".*' | sed 's@'"$path"'@@g' | sed 's@^/@@');
echo "$file";
fi
if echo "$p" | grep -q "<error.*" ; then
line="$(expr "$p" : '.*line=\"\([0-9]*\)\".*')";
message="$(expr "$p" : '.*message=\"\(.*\)\" source.*' | sed -e 's/'/`/g' -e 's/</</g' -e 's/>/>/g' -e 's/"/\\\"/g' -e 's/&/\&/g')"
checksum=$(echo "$file $line $message" | sha1sum | awk '{print $1}')
if [ "$first" == 1 ] ; then
echo "{ \"description\": \"$message\", \"fingerprint\": \"$checksum\", \"severity\": \"minor\", \"location\": { \"path\": \"$file\", \"lines\": { \"begin\": $line }}}" >> "$output";
first=0;
else
echo ",{ \"description\": \"$message\", \"fingerprint\": \"$checksum\", \"severity\": \"minor\", \"location\": { \"path\": \"$file\", \"lines\": { \"begin\": $line }}}" >> "$output"
fi
fi
done ;
echo "]" >> "$output"
artifacts:
paths:
- target/site/jacoco/
reports:
codequality:
- checkstyle-report.json
junit:
- target/surefire-reports/TEST-*.xml
show-coverage:
stage: test
needs:
- test
image: registry.gitlab.com/haynes/jacoco2cobertura:1.0.9
script:
- python /opt/cover2cover.py target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/src/main/java/ > coverage.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
check-license-headers:
stage: test
needs: []
cache:
<<: *cache
policy: pull
script:
- mvn license:check
deploy-gitlab:
stage: deploy
script:
- 'mvn deploy -s ci_settings.xml'
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH