-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
111 lines (105 loc) · 3.19 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
stages:
- build
- test
- deploy
- install
# 1) Build every commit on every branch and add the COMMIT SHORT SHA as suffix
maven-build:
stage: build
tags:
- shell
script:
- export MAVEN_OPTS='-Xmx128m'
- mvn clean install -DskipTests=true
artifacts:
paths:
- target
name: ${CI_PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_TAG != null
# 2) Run SonarQube Tests
sonarqube-check:
stage: test
tags:
- shell
dependencies:
- maven-build
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- mvn -Pcoverage verify sonar:sonar -Dsonar.host.url=https://sonar.dmx.systems -Dsonar.projectKey=${CI_PROJECT_NAMESPACE}_${CI_PROJECT_NAME}_${SONAR_PROJECT_KEY}
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_TAG != null
# 3) Copies SNAPSHOT builds on 'main' and 'dm4' branch into download.dmx.systems/ci/ directory
copy-to-ci:
stage: deploy
script:
- CIDIR='/var/www/download.dmx.systems/ci'
- DESTDIR="${CIDIR}/${CI_PROJECT_NAME}"
- JARFILE="$( basename $( ls target/*.jar | tail -n1) )"
- NUNC="$( date +%F )"
- DESTJARFILE="$( basename ${JARFILE} .jar )_${NUNC}_${CI_PIPELINE_ID}.jar"
- if [ ! -d ${DESTDIR} ]; then mkdir ${DESTDIR}; fi
- cp target/${JARFILE} ${DESTDIR}/${DESTJARFILE}
- ln -sf ${DESTDIR}/${DESTJARFILE} ${DESTDIR}/${CI_PROJECT_NAME}-latest.jar
dependencies:
- maven-build
only:
- master
- main
- dm4
# 4) Copies tagged RELEASE builds into download.dmx.systems/plugins/ directory
copy-to-release:
stage: deploy
script:
- RELEASEDIR='/var/www/download.dmx.systems/plugins'
- DESTDIR="${RELEASEDIR}/${CI_PROJECT_NAME}"
- JARFILE="$( basename $( ls target/*.jar | tail -n1) )"
- if [ ! -d ${DESTDIR} ]; then mkdir ${DESTDIR}; fi
- cp target/${JARFILE} ${DESTDIR}/
dependencies:
- maven-build
only:
- tags
# 5) Deploy into gitlab maven repository
deploy-to-gitlab-maven:
stage: deploy
tags:
- shell
#image: maven:3.6-jdk-11
script:
- 'mvn -Pgitlab-maven-deployment deploy -s ci_settings.xml'
only:
- master
- main
- dm4
allow_failure: true
# 6) Install in docker-container
install-in-container:
stage: install
tags:
## requires shell-docker runner
- shell-docker
dependencies:
- maven-build
script:
- deploy/ci-deploy-docker-instances.sh
## Test login of DMX LDAP Users
- sleep 3
- deploy/dmx-test-ldap-login.sh "testuser testuser1 testuser2"
#after_script:
# - docker compose --env-file "${ENV_FILE}" --file deploy/docker-compose.${TIER}-ci.yaml down -v --remove-orphans || true
# - docker image rm ${CI_PROJECT_NAME}_${CI_COMMIT_REF_SLUG}-ldap || true
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'main' && $CI_COMMIT_TAG == null