-
Notifications
You must be signed in to change notification settings - Fork 21
/
.gitlab-ci.yml
140 lines (129 loc) · 4.85 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
stages:
- test
- package
- deploy
variables:
COUNT_STATS_ARTIFACT_PATH: count-stats/target/count-stats-$ENVIRONMENT_NAME.war
RELEASE_ARTIFACT_PATH: eva-release/target/eva-release-$ENVIRONMENT_NAME.war
WS_ARTIFACT_PATH: eva-server/target/eva-$ENVIRONMENT_NAME.war
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-lib,eva-server,count-stats,eva-release' -Deva.mongo.host.test=mongo
only:
- master
- tags
# Not executed, parent job definition for package
.package:
image: maven:3.6.1-jdk-8-alpine
stage: package
environment:
name: $ENVIRONMENT_NAME
resource_group: $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-lib,eva-server,eva-release' --settings $MAVEN_SETTINGS -P $WS_MAVEN_PROFILE -DskipTests -Dtimestamp=$DATETIME
- mvn package --projects 'count-stats' --settings $MAVEN_SETTINGS -P $COUNT_STATS_MAVEN_PROFILE -DskipTests -Dtimestamp=$DATETIME
- cp eva-server/target/eva-*.war $WS_ARTIFACT_PATH
- cp eva-release/target/eva-*.war $RELEASE_ARTIFACT_PATH
- cp count-stats/target/count-stats-*.war $COUNT_STATS_ARTIFACT_PATH
after_script:
- rm $MAVEN_SETTINGS
artifacts:
expire_in: 1 week
paths:
- $WS_ARTIFACT_PATH
- $COUNT_STATS_ARTIFACT_PATH
- $RELEASE_ARTIFACT_PATH
package-internal:
extends: .package
variables:
WS_MAVEN_PROFILE: internal
COUNT_STATS_MAVEN_PROFILE: internal
ENVIRONMENT_NAME: internal
only:
- master
package-staging:
extends: .package
variables:
WS_MAVEN_PROFILE: production_processing
COUNT_STATS_MAVEN_PROFILE: production_processing
ENVIRONMENT_NAME: staging
only:
- master
package-production:
extends: .package
variables:
WS_MAVEN_PROFILE: production,$ACTIVE_EVAPRO
# COUNT_STATS_MAVEN_PROFILE is production_processing because we are writing to the staging metadata database
COUNT_STATS_MAVEN_PROFILE: production_processing
ENVIRONMENT_NAME: production
only:
- tags
# Not executed, parent job definition for Tomcat deployments
.deploy-tomcat:
stage: deploy
image: alpine:3.9.5
environment:
name: $ENVIRONMENT_NAME
resource_group: $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&version=$DATETIME" | grep "OK - Deployed application"
- curl -u $TOMCAT_USER:$TOMCAT_PASSWORD -T "$RELEASE_ARTIFACT_PATH" "http://$TOMCAT_HOST/manager/text/deploy?update=true&path=/eva/webservices/release&version=$DATETIME" | grep "OK - Deployed application"
- curl -u $TOMCAT_USER:$TOMCAT_PASSWORD -T "$COUNT_STATS_ARTIFACT_PATH" "http://$TOMCAT_HOST/manager/text/deploy?update=true&path=/eva/webservices/count-stats&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-staging:
extends: .deploy-tomcat
variables:
ENVIRONMENT_NAME: staging
TOMCAT_USER: $TOMCAT_DEVELOPMENT_USER
TOMCAT_PASSWORD: $TOMCAT_DEVELOPMENT_PASSWORD
TOMCAT_HOST: $TOMCAT_DEVELOPMENT_HOST
dependencies:
- package-staging
only:
- master
deploy-tomcat-production:
extends: .deploy-tomcat
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
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