-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci-dso.example.java.yml
71 lines (62 loc) · 1.69 KB
/
.gitlab-ci-dso.example.java.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
# Import des catalog des jobs CPiN
include:
- project: $CATALOG_PATH
file:
- vault-ci.yml
- kaniko-ci.yml
- java-mvn.yml
ref: main
# default:
# tags:
# - ADD_CUSTOM_TAG_HERE
# Definition des path à mettre en cache .m2/repository en cas de build java, node_modules pour les build nodejs
cache:
paths:
- .m2/repository/
- node_modules
# Variables générales au build
variables:
TAG: "${CI_COMMIT_REF_SLUG}"
DOCKERFILE: Dockerfile
REGISTRY_URL: "${IMAGE_REPOSITORY}"
# Differents stages du build. Le stage read-secret est obligatoire et permet de recuperer les secret CI du projet
stages:
- read-secret
- build-app
- docker-build
# Lecture des secrets CI du build
read_secret:
stage: read-secret
extends:
- .vault:read_secret
# Build de l'application, a adapter en fonciton de la technologie applicative. Peut egalement se faire a l'etape Docker dans le cas d'un multi stage build docker
package-app:
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
MAVEN_CLI_OPTS: ""
MVN_CONFIG_FILE: $MVN_CONFIG
BUILD_IMAGE_NAME: maven:3.8-openjdk-17
WORKING_DIR: .
ARTEFACT_DIR: ./target/*.jar
stage: build-app
extends:
- .java:build
sonar-app:
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
MAVEN_CLI_OPTS: ""
MVN_CONFIG_FILE: $MVN_CONFIG
BUILD_IMAGE_NAME: maven:3.8-openjdk-17
WORKING_DIR: .
ARTEFACT_DIR: ./target/*.jar
stage: sonar
extends:
- .java:sonar
# Docker build et push de l'image sur le repo Harbor
docker-build:
variables:
WORKING_DIR: "."
IMAGE_NAME: java-demo
stage: docker-build
extends:
- .kaniko:simple-build-push