This repository has been archived by the owner on Oct 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
101 lines (90 loc) · 2.77 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
image: $CI_REGISTRY_IMAGE/ci-base
services:
- docker:18.09.7-dind
# For predefined environment variables see: https://docs.gitlab.com/ee/ci/variables/
variables:
# Instruct Testcontainers to use the daemon of DinD.
# See further: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
DOCKER_HOST: "tcp://docker:2375"
# Improve performance with overlayfs.
# See further: https://docs.docker.com/storage/storagedriver/overlayfs-driver/
# See further: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
DOCKER_DRIVER: "overlay2"
IMAGE_TAG: "${CI_COMMIT_SHORT_SHA}-${CI_PIPELINE_ID}"
GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle"
# ODS related enviroment variables
ODS_IT_HOST: docker
ODS_IT_COUCHDB_HOST: docker
stages:
- build
- build-docker
- test
- deploy
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
cache:
paths:
- .gradle/wrapper
- .gradle/caches
build-ci-image:
stage: build
image: docker:stable
when: manual
script:
- docker build -t $CI_REGISTRY_IMAGE/ci-base ./docker/ci-base
- docker push $CI_REGISTRY_IMAGE/ci-base
build:
stage: build
script:
- "./gradlew assemble"
build-docker:
stage: build-docker
dependencies:
- build
script:
- "./gradlew copyDockerAssets"
- docker build -t ods-ci/ods ./docker/ods
- mkdir image
- docker save ods-ci/ods > image/ods-ci.tar
artifacts:
expire_in: 1 day
paths:
- image/
unit-tests:
stage: test
script: "./gradlew test"
artifacts:
reports:
junit: /*/build/test-results/test/**/TEST-*.xml
integration-test:
stage: test
dependencies:
- build-docker
retry: 2
script:
- docker load -i image/ods-ci.tar
- docker-compose -f docker/docker-compose.yml -f docker/docker-compose.local.yml up -d
- ./gradlew clean integrationTest
after_script:
- docker-compose -f docker/docker-compose.yml -f docker/docker-compose.local.yml down
publish-as-latest:
stage: deploy
dependencies:
- build-docker
when: manual
script:
- docker load -i image/ods-ci.tar
# Tag as latest and push
- docker tag ods-ci/ods $CI_REGISTRY_IMAGE/ods:latest
- docker push $CI_REGISTRY_IMAGE/ods:latest
publish-as-version:
stage: deploy
dependencies:
- build-docker
when: manual
script:
- docker load -i image/ods-ci.tar
# Tag as project version and push
- export ODS_VERSION=$(./gradlew properties -q | grep 'version:' | awk '{print $2}')
- docker tag ods-ci/ods $CI_REGISTRY_IMAGE/ods:$ODS_VERSION
- docker push $CI_REGISTRY_IMAGE/ods:$ODS_VERSION