This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
62 lines (55 loc) · 2.26 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
image: docker:git
services:
- docker:dind
# - docker:19.03.12-dind
stages:
- build
- deploy
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd`are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
# Cache downloaded dependencies and plugins between builds.
cache:
paths:
- .m2/repository/
- target/
mvn-package:
image: maven:3.6.3-openjdk-8
stage: build
script:
- >
DATE=$(date +%Y%m%d.%H%M)
- BRANCH=$(echo $CI_COMMIT_BRANCH | sed 's|^rel/||g' | sed 's|[.]|_|g' | awk -F/ '{ print $NF }')
- GIT_SHORT_COMMIT=$(echo $CI_COMMIT_SHA | cut -c1-8)
- IMAGE_TAG=$DATE.$BRANCH.$GIT_SHORT_COMMIT
- >
echo "\nIMAGE_TAG = $IMAGE_TAG"
- echo "$IMAGE_TAG" > IMAGE_TAG
- >
mvn $MAVEN_CLI_OPTS package -DskipTests
artifacts:
paths:
- IMAGE_TAG
- backend/webapp/target/contactapp.war
- backend/webapp/target/classes/docker/Dockerfile
- backend/webapp/target/classes/docker/entrypoint.sh
release:
stage: deploy
services:
- docker:dind
script:
- >
cp backend/webapp/target/contactapp.war .
- cp backend/webapp/target/classes/docker/Dockerfile .
- cp backend/webapp/target/classes/docker/entrypoint.sh .
- >
IMAGE_TAG=$(cat IMAGE_TAG)
- >
docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY/ecpnv.devops/apps/contactapp/contactapp:$IMAGE_TAG .
- docker push $CI_REGISTRY/ecpnv.devops/apps/contactapp/contactapp:$IMAGE_TAG