-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.gitlab-ci.yml
106 lines (99 loc) · 3.47 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
variables:
DOCKER_DRIVER: overlay2
GRADLE_OPTS:
value: -Dorg.gradle.daemon=false -Dorg.gradle.caching=true -Dorg.gradle.project.reckon.enabled=true
description: "Common Gradle options"
DEFAULT_JOB_IMAGE_NAME:
value: eclipse-temurin:17-jdk-alpine
include:
# Include some default job templates for various job types
- project: 'codebreeze-io/project-template/gitlab-template'
ref: '0.4'
file:
- 'gradle/micro-stageless-pipeline.gitlab-ci.yml'
- 'rule/deliver-job-auto-tag-rule.gitlab-ci.yml'
- 'workflow/mergerequest-then-branch-or-tag-workflow.gitlab-ci.yml'
# Add the release feature for this pipeline
- 'release/release-micro-stageless-pipeline.gitlab-ci.yml'
check:
variables:
POSTGRESQL_USERNAME: spring
POSTGRESQL_PASSWORD: boot
POSTGRESQL_DATABASE: app
SPRING_DATASOURCE_URL: jdbc:postgresql://postgresql/app
SPRING_DATASOURCE_USERNAME: spring
SPRING_DATASOURCE_PASSWORD: boot
SPRING_JPA_GENERATE_DDL: "true"
services:
- name: bitnami/postgresql:11
alias: postgresql
deliver:
#docker service only required for Spring boot buildpack
#services:
# - docker:19-dind
variables:
JIB_FROM_IMAGE: eclipse-temurin:17-jre-alpine
DELIVER_JOB_GRADLE_TASK_ARGS: publishBootJavaPublicationToGitLabRepository jib
# Run as extra job as it consumes a large amount of build time
deliver-native-image:
extends: deliver
image: "ghcr.io/graalvm/graalvm-ce:ol9-java17-22.3.1"
tags:
- "local-runner"
- "$OS-$ARCH"
needs:
- job: check
artifacts: true
variables:
DELIVER_JOB_GRADLE_TASK_ARGS: publishBootNativePublicationToGitLabRepository
rules:
- when: manual
parallel:
matrix:
- OS: darwin
ARCH: amd64
- OS: linux
ARCH: amd64
deploy:
extends: .default-job
image: ${CI_REGISTRY}/codebreeze-io/devops/nomad-cli:1.3.5-debian-slim
needs:
- job: deliver
artifacts: false # deliver pushed artifacts to registry and will be pulled by nomad
tags:
- nomad-cluster
cache: []
script:
- |
cd src/main/nomad
# NOMAD_ADDR must be provided as gitlab-runner environment variable
nomad namespace apply ${NOMAD_NAMESPACE}
nomad job run \
--namespace "${NOMAD_NAMESPACE}" \
--var environment="${NOMAD_NAMESPACE}" \
--var-file continuousdelivery-configuration.hcl \
--var api_image_tag=${API_IMAGE_TAG} \
--var registry_auth_username=${CI_REGISTRY_USER} \
--var registry_auth_password=${CI_REGISTRY_PASSWORD} \
--detach \
continuousdelivery.hcl
# TODO provide delivery rules as template in codebreeze-io/project-template/gitlab-gradle-template
rules:
# Manually deploy a tagged build
- if: '$CI_COMMIT_TAG'
when: manual # the default
variables:
NOMAD_NAMESPACE: production
API_IMAGE_TAG: $CI_COMMIT_TAG
# Manually deliver a feature branch build
- if: '$CI_COMMIT_BRANCH =~ /feature\/.*/'
when: manual
variables:
NOMAD_NAMESPACE: $CI_COMMIT_REF_SLUG
API_IMAGE_TAG: $CI_COMMIT_REF_SLUG
# Manually deliver a merge request build
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
variables:
NOMAD_NAMESPACE: $CI_COMMIT_REF_SLUG
API_IMAGE_TAG: $CI_COMMIT_REF_SLUG