-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
129 lines (118 loc) · 3.04 KB
/
.gitlab-ci.yml
File metadata and controls
129 lines (118 loc) · 3.04 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
image: openjdk:8
# Setup
stages:
- build
- test
- publish
- deploy
- integration
- clean
# Jobs
.template_prepare_kube: &prepare_kube
tags: [docker]
image: artifacts.int.corefiling.com:5000/pdds/kube-deploy:0.8.1
variables:
TILLER_NAMESPACE: $CI_ENVIRONMENT_SLUG
HELM_CHART: integration-tests
before_script:
- export IMAGE_TAG=`cat build.version`
- echo "IMAGE_TAG=$IMAGE_TAG"
- echo "TILLER_NAMESPACE=$TILLER_NAMESPACE"
- /kube/init $KUBE_AUTH_TOKEN $TILLER_NAMESPACE
.template-gradle: &gradle
tags:
- docker
variables: &gradle_variables
JAVA_OPTS: -DbuildInfo.build.number=pipeline-$CI_PIPELINE_ID -Dorg.gradle.daemon=false
GRADLE_TASK: $CI_JOB_NAME
GRADLE_USER_HOME: /opt/gradle/caches
cache: &cache
key: '$CI_BUILD_REF_NAME'
untracked: true
policy: pull
script: '"$CI_PROJECT_DIR/gradlew" --stacktrace "$CI_JOB_NAME"'
assemble:
<<: *gradle
stage: build
cache:
<<: *cache
policy: push
build version:
stage: build
tags:
- docker
image: artifacts.int.corefiling.com:5000/beacon/beacon/ci-build-version:local
artifacts:
expire_in: 1 week
paths:
- build.version
script:
- ci-build-version -b `cat gradle.properties | grep "^version = " | sed 's/version = //'` > build.version
test: *gradle
publish:
<<: *gradle
tags:
- docker
- docker-privileged
stage: publish
services:
- docker:dind
variables:
<<: *gradle_variables
DOCKER_HOST: tcp://docker:2375
publish chart:
<<: *prepare_kube
stage: publish
dependencies:
- build version
before_script: []
script:
- export BUILD_VERSION=$(cat build.version)
- cd charts/
- sed -ri -e s/0.0.0-local/${BUILD_VERSION}/ digit-frequency-analysis-service/*.yaml integration-tests/*.yaml
- 'sed -ri -e "s/imageTag: dev/imageTag: ${BUILD_VERSION}/" digit-frequency-analysis-service/values.yaml'
- /kube/helmPush digit-frequency-analysis-service
deploy:service:
<<: *prepare_kube
stage: deploy
environment: &environment
name: $CI_PROJECT_NAMESPACE-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG
dependencies:
- build version
- publish
- publish chart
artifacts:
expire_in: 1 week
paths:
- service.url
script:
- BASE_DOMAIN="$TILLER_NAMESPACE.kube.int.corefiling.com"
- SERVICE_URL="https://$BASE_DOMAIN/"
- echo "$SERVICE_URL" > service.url
- echo "Deploying to $SERVICE_URL"
- cd charts
- helm dependency update $HELM_CHART
- helm upgrade --install
--set ingress.host=$BASE_DOMAIN
--set digit-frequency-analysis-service.imageTag=$IMAGE_TAG
--namespace=$TILLER_NAMESPACE
$HELM_CHART
$HELM_CHART
--debug
- /kube/checkRunning
testIntegration:
<<: *gradle
stage: integration
before_script:
- 'export JAVA_OPTS="$JAVA_OPTS -Dservice.url=`cat service.url`"'
dependencies:
- deploy:service
clean:undeploy:
<<: *prepare_kube
stage: clean
when: always
environment:
<<: *environment
action: stop
script:
- kube-auth namespace delete $TILLER_NAMESPACE