-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
140 lines (129 loc) · 3.74 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:
WS_ARTIFACT_PATH: target/eva-submission-ws-$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: ubuntu:latest
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y curl jq
script:
- |
for i in {1..5}; do
echo "Finding Github CI status for ${CI_COMMIT_SHA}..." && export GITHUB_CI_STATUS=$(curl -s https://api.github.com/repos/EBIVariation/eva-submission-ws/actions/runs | jq --arg COMMIT_TO_FIND $CI_COMMIT_SHA -r '.workflow_runs | map(select(.head_sha == $COMMIT_TO_FIND and .conclusion == "success"))[0].conclusion') && [[ $GITHUB_CI_STATUS == "success" ]] && echo "Github CI run was successful!"
if [ $? -ne 0 ]; then
echo "Retrying..."
sleep 300
else
exit 0
fi
done
exit 1
environment:
name: test-env
only:
- main
- 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 --settings $MAVEN_SETTINGS -P $MAVEN_PROFILE -DskipTests
- cp target/eva-submission-ws*.war.original $WS_ARTIFACT_PATH
after_script:
- rm $MAVEN_SETTINGS
artifacts:
paths:
- $WS_ARTIFACT_PATH
package-internal:
extends: .package
variables:
ENVIRONMENT_NAME: internal
MAVEN_PROFILE: internal
only:
- main
package-development:
extends: .package
variables:
ENVIRONMENT_NAME: development
MAVEN_PROFILE: development
only:
- main
package-production:
extends: .package
variables:
ENVIRONMENT_NAME: production
# Use production_processing to use production rather than public database
MAVEN_PROFILE: production_processing
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/submission-ws&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:
- main
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:
- main
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