-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
98 lines (89 loc) · 2.3 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
image: maven:3.6-jdk-11
stages:
- verify_source
- build
- test
- deploy
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
cache:
paths:
- .m2/repository/
verify_release:
stage: verify_source
tags: ["docker"]
only:
- tags
script:
- export PROJECT_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- >
if [[ "$PROJECT_VERSION" == *SNAPSHOT ]]; then
echo "a release version can't be a snapshot (project.version=$PROJECT_VERSION)"
exit 1
fi
- >
if [ "$PROJECT_VERSION" != "$CI_COMMIT_TAG" ]; then
echo "project.version doesn't match git tag (project.version=$PROJECT_VERSION, git.tag=$CI_COMMIT_TAG)"
exit 1
fi
compile:
stage: build
tags: ["docker"]
script: mvn $MAVEN_CLI_OPTS compile
unit_tests:
stage: test
tags: ["docker"]
script: mvn $MAVEN_CLI_OPTS verify
artifacts:
reports:
junit:
- target/surefire-reports/TEST-*.xml
- target/failsafe-reports/TEST-*.xml
integration_tests:
stage: test
tags: ["docker"]
script:
- mvn $MAVEN_CLI_OPTS -DhttpBinDomain=httpbin -P integration-test verify
- cat target/site/jacoco/index.html
services:
- name: "kennethreitz/httpbin"
alias: "httpbin"
artifacts:
reports:
junit:
- target/surefire-reports/TEST-*.xml
- target/failsafe-reports/TEST-*.xml
deploy_snapshot:
stage: deploy
tags: ["docker"]
only:
- master
before_script:
- export PROJECT_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- >
if [[ "$PROJECT_VERSION" != *SNAPSHOT ]]; then
echo "not a snapshot version, not deploying"
exit 1
fi
- gpg -v --import <(echo "$GPG_SIGNING_KEY")
- gpg --list-key
script:
- mvn $MAVEN_CLI_OPTS -P release -DskipTests=true deploy
artifacts:
paths:
- "target/"
deploy_release:
stage: deploy
tags: ["docker"]
only:
- tags
before_script:
- export PROJECT_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- gpg -v --import <(echo "$GPG_SIGNING_KEY")
- gpg --list-key
script:
- mvn $MAVEN_CLI_OPTS -P release -DskipTests=true deploy
artifacts:
paths:
- "target/"