-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
185 lines (168 loc) · 4.91 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
variables:
### Disable cache in Docker builds, as this has occasionally resulted in images not containing what was
### expected multiple MRs where being built/retried.
NO_CACHE: 'true'
### Replace RESOURCE with the name of the image you want to build and publish in OpenShift
### Important! In order for this template to work, the name of the gitlab repo must match
### also the variable name
RESOURCE: storage-api
###
### You shouldn't change the following variables
NAMESPACE: it-db-storage-api
OPENSHIFT_SERVER: https://openshift-dev.cern.ch
stages:
- test
- build
- provision
- deploy
perform-tests:
stage: test
image: python:3
before_script:
- pip install -r requirements.txt
- python setup.py install
script:
- make test
build-docker-dev:
stage: build
only:
- branches
except:
- master
tags:
- docker-image-build
script:
- "echo 'Building Docker dev image..'"
variables:
TO: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
build-docker-tag:
stage: build
only:
- tags
tags:
- docker-image-build
script: "echo building $CI_REGISTRY_IMAGE" # No empty scripts are allowed
variables:
TO: $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG} # Where to push resulting image
build-docker-latest:
stage: build
only:
- master
tags:
- docker-image-build
script: "echo 'Building Docker image...'"
build-doc:
image: python:3
artifacts:
paths:
- html
when: always
stage: build
allow_failure: true
before_script:
- curl -sL https://deb.nodesource.com/setup_6.x | bash -
- apt-get update && apt-get install -y nodejs
- pip install -r requirements.txt
- python setup.py install
- npm install -g spectacle-docs
script:
- make html
# - make doc_deploy
deploy-doc:
stage: deploy
# Previous job, that buils the doc is not working correctly. Must be fixed
allow_failure: true
only:
- master
- tags
image: gitlab-registry.cern.ch/ci-tools/ci-web-deployer:latest
script:
- deploy-dfs
lint:
image: python:3
stage: test
allow_failure: true
before_script:
- pip install flake8
script:
- make lint
## Ugly hack: tag whatever tagged image we built as :latest on
## OpenShift, causing it to (re)deploy that. Unfortunately, OpenShift
## does not speak versions, as far as I understand it. Also, for good
## measure: actually import the image.
dev-deploy:
when: manual
only:
- branches
except:
- master
stage: deploy
environment: dev
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc tag --token=${TOKEN} --server=${OPENSHIFT_SERVER} --namespace test-${NAMESPACE} --source=docker gitlab-registry.cern.ch/db/storage/${RESOURCE}:${CI_COMMIT_REF_NAME} ${RESOURCE}:latest
variables:
TOKEN: ${IMPORT_TOKEN_DEV}
GIT_STRATEGY: none
prod-deploy-tag:
when: manual
only:
- tags
stage: deploy
environment: prod
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc tag --token=${TOKEN} --server=${OPENSHIFT_SERVER} --namespace ${NAMESPACE} --source=docker gitlab-registry.cern.ch/db/storage/${RESOURCE}:${CI_COMMIT_TAG:-latest} ${RESOURCE}:latest
variables:
TOKEN: ${IMPORT_TOKEN_PROD}
GIT_STRATEGY: none
OPENSHIFT_SERVER: https://openshift.cern.ch
prod-deploy-latest:
when: manual
only:
- master
stage: deploy
environment: prod
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc tag --token=${TOKEN} --server=${OPENSHIFT_SERVER} --namespace ${NAMESPACE} --source=docker gitlab-registry.cern.ch/db/storage/${RESOURCE}:latest ${RESOURCE}:latest
variables:
TOKEN: ${IMPORT_TOKEN_PROD}
GIT_STRATEGY: none
OPENSHIFT_SERVER: https://openshift.cern.ch
# We might want to deploy the latest image in the dev instance of the application
dev-deploy-latest:
when: manual
only:
- master
stage: deploy
environment: dev
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc tag --token=${TOKEN} --server=${OPENSHIFT_SERVER} --namespace test-${NAMESPACE} --source=docker gitlab-registry.cern.ch/db/storage/${RESOURCE}:latest ${RESOURCE}:latest
variables:
TOKEN: ${IMPORT_TOKEN_DEV}
GIT_STRATEGY: none
dev-template:
stage: provision
environment: dev
only:
- branches
except:
- master
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc replace template --token=${TOKEN} --server=${OPENSHIFT_SERVER} -n test-${NAMESPACE} -f storage-api-openshift-template.yaml
variables:
TOKEN: ${IMPORT_TOKEN_DEV}
prod-template:
stage: provision
environment: prod
only:
- master
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc replace template --token=${TOKEN} --server=${OPENSHIFT_SERVER} -n ${NAMESPACE} -f storage-api-openshift-template.yaml
variables:
TOKEN: ${IMPORT_TOKEN_PROD}
OPENSHIFT_SERVER: https://openshift.cern.ch