forked from axelor/axelor-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
120 lines (106 loc) · 2.66 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
# Stages (ie phases) that can be used by jobs
stages:
- build
- test
- publish
image: axelor/app-builder:6.1
variables:
GIT_SUBMODULE_STRATEGY: recursive
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
# Add wrapper and caches folders in cache
.global_cache: &global_cache
paths:
- .gradle
- build
policy: pull-push
.global_cache_pull: &global_cache_pull
<<: *global_cache
policy: pull
# Trigger only relevant pipelines (avoid duplicates)
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_REF_PROTECTED == "true"
# Build artifacts
build:
stage: build
cache:
- *global_cache
allow_failure: false
script:
- ./gradlew -xtest -xspotlessApply -xlicenseFormat clean build
interruptible: true
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
# Check code formatting
spotless:
stage: test
cache:
- *global_cache_pull
allow_failure: true
script:
- ./gradlew spotlessCheck
interruptible: true
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
# Run tests
test:
stage: test
cache:
- *global_cache
allow_failure: false
script:
- ./gradlew test
interruptible: true
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
artifacts:
expire_in: 31d
paths:
- build/reports/jacoco
reports:
junit: build/test-results/test/**/TEST-*.xml
javadoc:
stage: test
cache:
- *global_cache
allow_failure: false
script:
- ./gradlew javadoc
interruptible: true
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
.publish_template: &publish_configuration
stage: publish
cache:
- *global_cache_pull
script:
- ./gradlew -xtest -xspotlessApply -xlicenseFormat clean build publish -PaddonsMavenUsername=${NEXUS_ADDONS_DEPLOYMENT_USER} -PaddonsMavenPassword=${NEXUS_ADDONS_DEPLOYMENT_PASSWORD} -P${PUBLISH_TYPE}
publish snapshot:
<<: *publish_configuration
variables:
PUBLISH_TYPE: "snapshotRelease"
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
publish release:
<<: *publish_configuration
variables:
PUBLISH_TYPE: "finalRelease"
rules:
- if: '$CI_COMMIT_TAG'
create release:
stage: publish
image: registry.gitlab.com/gitlab-org/release-cli:latest
cache:
- *global_cache_pull
allow_failure: true
rules:
- if: '$CI_COMMIT_TAG'
script:
- echo "create release for $CI_COMMIT_TAG"
- |
RELEASE_DESCRIPTION=$(sed -n "/^## ${CI_COMMIT_TAG}/,/^## /p" CHANGELOG.md | sed '$d;$d')
release-cli create --name "$CI_COMMIT_TAG" --description "$RELEASE_DESCRIPTION" --tag-name "$CI_COMMIT_TAG" --ref "$CI_COMMIT_TAG"