forked from EBIvariation/eva-accession
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
313 lines (289 loc) · 10.2 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
stages:
- test
- package
- deploy
variables:
WS_ARTIFACT_PATH: eva-accession-ws/target/eva-accession-ws-$ENVIRONMENT_NAME.war
CLUSTERING_ARTIFACT_PATH: eva-accession-clustering/target/eva-accession-clustering-*exec.jar
ACCESSIONING_ARTIFACT_PATH: eva-accession-pipeline/target/eva-accession-pipeline-*exec.jar
RELEASE_ARTIFACT_PATH: eva-accession-release/target/eva-accession-release-*exec.jar
DEPRECATE_ARTIFACT_PATH: eva-accession-deprecate/target/eva-accession-deprecate-*exec.jar
REMAPPING_GET_SOURCE_ARTIFACT_PATH: eva-remapping-get-source/target/eva-remapping-get-source-*exec.jar
REMAPPING_INGEST_ARTIFACT_PATH: eva-remapping-ingest/target/eva-remapping-ingest-*exec.jar
CLUSTERING_SYMLINK_NAME: "eva-accession-clustering.jar"
ACCESSIONING_SYMLINK_NAME: "eva-accession-pipeline.jar"
RELEASE_SYMLINK_NAME: "eva-accession-release.jar"
DEPRECATE_SYMLINK_NAME: "eva-accession-deprecate.jar"
REMAPPING_GET_SOURCE_SYMLINK_NAME: "eva-remapping-get-source.jar"
REMAPPING_INGEST_SYMLINK_NAME: "eva-remapping-ingest.jar"
MAVEN_SETTINGS: maven-settings.xml
URL_MAVEN_SETTINGS: https://api.github.com/repos/EBIvariation/configuration/contents/eva-maven-settings.xml
MEDIA_TYPE: application/vnd.github.raw
test:
stage: test
image: maven:3.6.1-jdk-8-alpine
services:
- mongo:4.0.18
script:
# Gitlab exposes services under their own hostnames. So test host should be "mongo" instead of "localhost".
- mvn clean test --projects 'eva-accession-core,eva-accession-deprecate,eva-accession-ws,eva-remapping-get-source,eva-accession-clustering,eva-accession-pipeline,eva-accession-release,eva-remapping-ingest' -Deva.mongo.host.test=mongo
environment:
name: test-env
only:
- master
- tags
# Not executed, parent job definition for package
.package:
stage: package
image: maven:3.6.1-jdk-8-alpine
environment:
name: $ENVIRONMENT_NAME
before_script:
- DATETIME=$(date +%Y-%m-%dT%H-%M-%S)
- apk add --update curl
- curl -u $GITHUB_USER:$GITHUB_TOKEN -H "Accept:$MEDIA_TYPE" $URL_MAVEN_SETTINGS > $MAVEN_SETTINGS
script:
- mvn package --projects 'eva-accession-core,eva-accession-ws,eva-remapping-get-source,eva-accession-clustering,eva-accession-pipeline,eva-accession-release,eva-accession-deprecate,eva-remapping-ingest' --settings $MAVEN_SETTINGS -P $MAVEN_PROFILE -DskipTests -Dtimestamp=$DATETIME
- cp eva-accession-ws/target/eva*.war $WS_ARTIFACT_PATH
after_script:
- rm $MAVEN_SETTINGS
artifacts:
paths:
- $WS_ARTIFACT_PATH
- $CLUSTERING_ARTIFACT_PATH
- $ACCESSIONING_ARTIFACT_PATH
- $RELEASE_ARTIFACT_PATH
- $DEPRECATE_ARTIFACT_PATH
- $REMAPPING_GET_SOURCE_ARTIFACT_PATH
- $REMAPPING_INGEST_ARTIFACT_PATH
package-internal:
extends: .package
variables:
ENVIRONMENT_NAME: internal
MAVEN_PROFILE: internal
only:
- master
package-development:
extends: .package
variables:
ENVIRONMENT_NAME: development
MAVEN_PROFILE: production_processing
only:
- master
package-production:
extends: .package
variables:
ENVIRONMENT_NAME: production
MAVEN_PROFILE: production
only:
- tags
# Not executed, parent job definition for deployments
.deploy-tomcat:
stage: deploy
image: alpine:3.9.5
environment:
name: $ENVIRONMENT_NAME
script:
- DATETIME=$(date +%Y-%m-%dT%H-%M-%S)
- apk add --update curl
- curl -u $TOMCAT_USER:$TOMCAT_PASSWORD -T "$WS_ARTIFACT_PATH" "http://$TOMCAT_HOST/manager/text/deploy?update=true&path=/eva/webservices/identifiers&version=$DATETIME" | grep "OK - Deployed application"
deploy-tomcat-internal:
extends: .deploy-tomcat
variables:
ENVIRONMENT_NAME: internal
TOMCAT_USER: $TOMCAT_INTERNAL_USER
TOMCAT_PASSWORD: $TOMCAT_INTERNAL_PASSWORD
TOMCAT_HOST: $TOMCAT_INTERNAL_HOST
dependencies:
- package-internal
only:
- master
deploy-tomcat-development:
extends: .deploy-tomcat
variables:
ENVIRONMENT_NAME: development
TOMCAT_USER: $TOMCAT_DEVELOPMENT_USER
TOMCAT_PASSWORD: $TOMCAT_DEVELOPMENT_PASSWORD
TOMCAT_HOST: $TOMCAT_DEVELOPMENT_HOST
dependencies:
- package-development
only:
- master
deploy-tomcat-production:
extends: .deploy-tomcat
when: manual
variables:
ENVIRONMENT_NAME: production
TOMCAT_USER: $TOMCAT_PRODUCTION_USER
TOMCAT_PASSWORD: $TOMCAT_PRODUCTION_PASSWORD
TOMCAT_HOST: $TOMCAT_PRODUCTION_HOST
dependencies:
- package-production
only:
- tags
deploy-tomcat-production-fallback:
extends: .deploy-tomcat
when: manual
variables:
ENVIRONMENT_NAME: production
TOMCAT_USER: $TOMCAT_PRODUCTION_FALLBACK_USER
TOMCAT_PASSWORD: $TOMCAT_PRODUCTION_FALLBACK_PASSWORD
TOMCAT_HOST: $TOMCAT_PRODUCTION_FALLBACK_HOST
dependencies:
- package-production
only:
- tags
# Not executed, parent job definition for deployments of jar files
.deploy-jar:
stage: deploy
image: alpine:3.9.5
environment:
name: $ENVIRONMENT_NAME
script:
# Start ssh-agent and set identity then copy the Jar file and create a symlink
# See https://docs.gitlab.com/ee/ci/ssh_keys/
- apk add --update openssh-client
- eval "$(ssh-agent)"
- echo "$EVA_ETL_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- TMP_NAME=$(basename $(ls $ARTIFACT_PATH))
- ARTIFACT_NAME=${TMP_NAME%%.jar}-${ENVIRONMENT_NAME}.jar
- scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $ARTIFACT_PATH ${CLUSTER_USER}@${CLUSTER_LOGIN_NODE_CODON}:${EVA_SOFTWARE_PATH_CODON}/eva-accession/${DEPLOY_DIRECTORY}/${ARTIFACT_NAME}
- ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${CLUSTER_USER}@${CLUSTER_LOGIN_NODE_CODON} "ln -fns ${EVA_SOFTWARE_PATH_CODON}/eva-accession/${DEPLOY_DIRECTORY}/${ARTIFACT_NAME} ${EVA_SOFTWARE_PATH_CODON}/eva-accession/${DEPLOY_DIRECTORY}/${SYMLINK_NAME}"
deploy-clustering-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $CLUSTERING_ARTIFACT_PATH
DEPLOY_DIRECTORY: clustering_development
SYMLINK_NAME: $CLUSTERING_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-accessioning-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $ACCESSIONING_ARTIFACT_PATH
DEPLOY_DIRECTORY: accessioning_development
SYMLINK_NAME: $ACCESSIONING_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-release-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $RELEASE_ARTIFACT_PATH
DEPLOY_DIRECTORY: release_development
SYMLINK_NAME: $RELEASE_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-deprecate-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $DEPRECATE_ARTIFACT_PATH
DEPLOY_DIRECTORY: deprecate_development
SYMLINK_NAME: $DEPRECATE_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-remapping-ingestion-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $REMAPPING_INGEST_ARTIFACT_PATH
DEPLOY_DIRECTORY: remapping_ingestion_development
SYMLINK_NAME: $REMAPPING_INGEST_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-remapping-get-source-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $REMAPPING_GET_SOURCE_ARTIFACT_PATH
DEPLOY_DIRECTORY: remapping_exporter_development
SYMLINK_NAME: $REMAPPING_GET_SOURCE_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-clustering-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $CLUSTERING_ARTIFACT_PATH
DEPLOY_DIRECTORY: clustering_production
SYMLINK_NAME: $CLUSTERING_SYMLINK_NAME
dependencies:
- package-production
only:
- tags
deploy-accessioning-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $ACCESSIONING_ARTIFACT_PATH
DEPLOY_DIRECTORY: accessioning_production
SYMLINK_NAME: $ACCESSIONING_SYMLINK_NAME
dependencies:
- package-production
only:
- tags
deploy-release-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $RELEASE_ARTIFACT_PATH
DEPLOY_DIRECTORY: release_production
SYMLINK_NAME: $RELEASE_SYMLINK_NAME
dependencies:
- package-production
only:
- tags
deploy-deprecate-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $DEPRECATE_ARTIFACT_PATH
DEPLOY_DIRECTORY: deprecate_production
SYMLINK_NAME: $DEPRECATE_SYMLINK_NAME
dependencies:
- package-production
only:
- tags
deploy-remapping-ingestion-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $REMAPPING_INGEST_ARTIFACT_PATH
DEPLOY_DIRECTORY: remapping_ingestion_production
SYMLINK_NAME: $REMAPPING_INGEST_SYMLINK_NAME
dependencies:
- package-production
only:
- tags
deploy-remapping-get-source-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $REMAPPING_GET_SOURCE_ARTIFACT_PATH
DEPLOY_DIRECTORY: remapping_exporter_production
SYMLINK_NAME: $REMAPPING_GET_SOURCE_SYMLINK_NAME
dependencies:
- package-production
only:
- tags