-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
81 lines (72 loc) · 2 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
image: gradle:jdk11
variables:
CI: "true"
GIT_STRATEGY: clone
GIT_FETCH_EXTRA_FLAGS: --tags
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
include:
- template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
.base-rule:
rules:
# always run on master/main
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
# only run pipeline on MRs to prevent duplicated pipelines
- if: '$CI_PIPELINE_SOURCE == "push"'
when: never
# don't run on pushed tags either
- if: $CI_COMMIT_TAG
when: never
# manually triggering is ok
- when: manual
allow_failure: true
stages: # List of stages for jobs, and their order of execution
- prerequisites
- build
- test
- publish
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
release-prerequisites-job: # runs the verifyRelease task from the axion-release plugin
stage: prerequisites
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- ./gradlew verifyRelease
build:
stage: build
script: gradle --build-cache assemble
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- build
- .gradle
test:
stage: test
script: gradle check
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
artifacts:
reports:
junit: [ "build/test-results/test/*.xml" ]
# everytime we merge a branch into the main
release:
environment: production
stage: publish
script:
- git config user.name "Gitlab Ci/CD pipeline"
- git config user.email [email protected]
- GIT_URL=`echo $CI_PROJECT_URL | sed -e "s|https://|https://oauth2:$PipelineReleasesPAT@|g"` # add authentication via token
- ./gradlew changelogBump -Prelease=true
- git add .
- git commit -am "Bump release version"
- ./gradlew createRelease --info --stacktrace
- git push --tags $GIT_URL # push via https & Gitlab Project Authentication Token (PAT)
- ./gradlew publish # publish latest version
rules:
- if: $CI_COMMIT_BRANCH == "main"