-
Notifications
You must be signed in to change notification settings - Fork 11
/
.gitlab-ci.yml
101 lines (94 loc) · 2.98 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
#
# To set up a scheduled pipeline in GitLab:
# Repository Home > Build (left menu) > Pipeline schedules > New Schedule
#
stages:
- build
- release
services:
- name: docker:dind
command:
- '--tls=false'
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ''
DOCKER_DRIVER: overlay2
MAVEN_OPTS: -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
build:
stage: build
image: ubuntu:24.04
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"
cache:
key: build-cache
paths:
- .m2/repository
before_script:
- apt update
- apt -y install curl zip unzip
- curl -s "https://get.sdkman.io?rcupdate=false" | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
script:
- sdk env install
- ./mvnw
publish:
stage: release
image: maven:3
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"
before_script:
- apt update
- apt -y install curl zip unzip
- curl -s "https://get.sdkman.io?rcupdate=false" | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
script:
- sdk env install
- export REGISTRY_USERNAME="${CI_REGISTRY_USER}"
- export REGISTRY_PASSWORD="${CI_REGISTRY_PASSWORD}"
- export CLIENT_PATH='target/generated-sources/openapi'
- export CONTROLLERS_PATH='com/github/jaguililla/appointments/http/controllers'
- export REPOSITORY="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven"
- export ALT_REPOSITORY="altDeploymentRepository=gitlab::default::${REPOSITORY}"
- export IMG_REGISTRY="image.registry=${CI_REGISTRY}/jaguililla/hexagonal_spring"
- export POM_VERSION="$(mvn help:evaluate -D expression=project.version -q -D forceStdout)"
- export CI_PUBLISH="spring-boot.build-image.publish=true"
- export MAVEN_ARGS="--quiet --batch-mode --settings .gitlab/ci_settings.xml"
- ./mvnw -D ${ALT_REPOSITORY} -D ${IMG_REGISTRY} -D ${CI_PUBLISH} deploy
- rm -rf "${CLIENT_PATH}/src/main/java/${CONTROLLERS_PATH}"
- mvn -f "${CLIENT_PATH}/pom.xml" -D ${ALT_REPOSITORY} clean deploy
- echo "POM_VERSION=${POM_VERSION}" >> variables.env
artifacts:
reports:
dotenv: variables.env
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: publish
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- echo "Release version ${POM_VERSION}"
release:
tag_name: ${POM_VERSION}
description: Release ${POM_VERSION}
nightly:
stage: build
image: ubuntu:24.04
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
cache:
key: build-cache
paths:
- .m2/repository
before_script:
- apt update
- apt -y install curl zip unzip
- curl -s "https://get.sdkman.io?rcupdate=false" | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
script:
- sdk env install
# TODO Enable ITs when nightly tests are fixed
- ./mvnw -P pitest -D skipITs
- ./mvnw -P gatling -D skipITs