forked from EBIvariation/eva-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
107 lines (98 loc) · 3.53 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
stages:
- test
- package
- deploy
variables:
PIPELINE_ARTIFACT_PATH: target/eva-pipeline-*.jar
PIPELINE_SYMLINK_NAME: "eva-pipeline.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: ubuntu:20.04
services:
- mongo:4.0.18
before_script:
- apt-get update
- apt-get install -y wget
- apt-get install -y openjdk-8-jdk
- java -version
- apt-get install -y maven
- mvn -version
- wget -q https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.6.1.deb
- apt install ./mongodb-database-tools-ubuntu2004-x86_64-100.6.1.deb
- mongorestore --version
script:
# Gitlab exposes services under their own hostnames. So test host should be "mongo" instead of "localhost".
- mvn clean test -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
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
after_script:
- rm $MAVEN_SETTINGS
artifacts:
paths:
- $PIPELINE_ARTIFACT_PATH
package-development:
extends: .package
variables:
MAVEN_PROFILE: production_processing
only:
- master
package-production:
extends: .package
variables:
MAVEN_PROFILE: 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-pipeline/${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-pipeline/${DEPLOY_DIRECTORY}/${ARTIFACT_NAME} ${EVA_SOFTWARE_PATH_CODON}/eva-pipeline/${DEPLOY_DIRECTORY}/${SYMLINK_NAME}"
deploy-pipeline-jar-development:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: development
ARTIFACT_PATH: $PIPELINE_ARTIFACT_PATH
DEPLOY_DIRECTORY: eva_pipeline_development
SYMLINK_NAME: $PIPELINE_SYMLINK_NAME
dependencies:
- package-development
only:
- master
deploy-pipeline-jar-production:
extends: .deploy-jar
variables:
ENVIRONMENT_NAME: production
ARTIFACT_PATH: $PIPELINE_ARTIFACT_PATH
DEPLOY_DIRECTORY: eva_pipeline_production
SYMLINK_NAME: $PIPELINE_SYMLINK_NAME
dependencies:
- package-production
only:
- tags