forked from EBIvariation/eva-accession
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
168 lines (154 loc) · 5.24 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
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-*.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:3.2.17
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-ws' -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-accession-clustering ' --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
package-internal:
extends: .package
variables:
ENVIRONMENT_NAME: internal
MAVEN_PROFILE: internal
only:
- master
package-development:
extends: .package
variables:
ENVIRONMENT_NAME: development
MAVEN_PROFILE: development
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 $CLUSTERING_ARTIFACT_PATH))
- CLUSTERING_ARTIFACT_NAME=${TMP_NAME%%.jar}-${ENVIRONMENT_NAME}.jar
- scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $CLUSTERING_ARTIFACT_PATH ${CLUSTER_USER}@${CLUSTER_LOGIN_NODE}:${CLUSTERING_PATH}/${CLUSTERING_ARTIFACT_NAME}
- ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${CLUSTER_USER}@${CLUSTER_LOGIN_NODE} "ln -fns ${CLUSTERING_PATH}/${CLUSTERING_ARTIFACT_NAME} ${CLUSTERING_PATH}/eva-accession-clustering.jar"
deploy-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
CLUSTERING_PATH: $CLUSTERING_DEVELOPMENT_PATH
dependencies:
- package-development
only:
- master
deploy-jar-production:
extends: .deploy-jar
when: manual
variables:
ENVIRONMENT_NAME: production
CLUSTERING_PATH: $CLUSTERING_PRODUCTION_PATH
dependencies:
- package-production
only:
- tags