-
Notifications
You must be signed in to change notification settings - Fork 2
/
.sample.gitlab-ci.yml
87 lines (82 loc) · 2.87 KB
/
.sample.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
stages:
- publish
- deployDev
- deployProd
variables:
OPENSHIFT_SERVER: https://openshift.ext.cetic.be:8443
OPENSHIFT_DOMAIN: openshift.ext.cetic.be
# Configure this variable in Secure Variables:
# OPENSHIFT_DEV_TOKEN: my.openshift.token
# OPENSHIFT_PROD_TOKEN: my.openshift.token
NEXUS_SERVER: http://nexus.ext.cetic.be:8083
NEXUS_USER: nexus-gitlab-ci
# Configure Nexus password in Secure Variables:
# NEXUS_PASSWORD: my.nexus.password
publish:
stage: publish
before_script:
# openjdk-8-jdk, sbt and docker have been installed on the shared shell runner.
# Nexus server URL has been added to the /etc/docker/daemon.json as "insecure-registries".
# check version of Docker
- docker --version
script:
# login to Nexus Docker repository
- docker login -u "$NEXUS_USER" -p "$NEXUS_PASSWORD" "$NEXUS_SERVER"
# build tsimulus-saas
- sbt clean package
# publish Backend Docker image to Nexus Repository
- sbt "backend/docker:publish"
tags:
- shared
.deploy: &deploy
image: ebits/openshift-client
script:
- echo deploy to OpenShift
# remove old pods
- "oc get services $APP 2> /dev/null && oc delete -f k8s/tsaas-backend-statefulset.yml"
- "oc get services $APP_SWAGGER 2> /dev/null && oc delete -f k8s/tsaas-swagger-ui-deployment.yml"
- "oc get configmap swagger-config 2> /dev/null && oc delete configmap swagger-config"
## Issue when trying to delete the statefulset https://github.com/kubernetes/kubernetes/issues/59867 Bug car pas même version de kubectl client - seveur
# create swagger configMap
- "oc create configmap swagger-config --from-file=oas/api-doc/"
# create new pods
- "oc create -f k8s/tsaas-backend-statefulset.yml"
- "oc get routes $APP 2> /dev/null || oc expose service $APP --hostname=$APP_HOST"
- "oc create -f k8s/tsaas-swagger-ui-deployment.yml"
- "oc get routes $APP_SWAGGER 2> /dev/null || oc expose service $APP_SWAGGER --hostname=$APP_SWAGGER_HOST"
tags:
- docker
deployDev:
stage: deployDev
before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_DEV_TOKEN" --insecure-skip-tls-verify
- oc project $PROJECT
<<: *deploy
variables:
PROJECT: tsaas-dev
APP: tsaas-backend
APP_SWAGGER: tsaas-swagger-ui
APP_HOST: tsaas-dev-api.$OPENSHIFT_DOMAIN
APP_SWAGGER_HOST: tsaas-dev-swagger-ui.$OPENSHIFT_DOMAIN
environment:
name: develop
url: http://tsaas-dev-api.$OPENSHIFT_DOMAIN
only:
- develop
deployProd:
stage: deployProd
before_script:
- oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_PROD_TOKEN" --insecure-skip-tls-verify
- oc project $PROJECT
<<: *deploy
variables:
PROJECT: tsaas-prod
APP: tsaas-backend
APP_SWAGGER: tsaas-swagger-ui
APP_HOST: tsaas-prod-api.$OPENSHIFT_DOMAIN
APP_SWAGGER_HOST: tsaas-prod-swagger-ui.$OPENSHIFT_DOMAIN
environment:
name: production
url: http://tsaas-prod-api.$OPENSHIFT_DOMAIN
only:
- master