-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitlab-ci.yml
65 lines (59 loc) · 1.87 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
image: openjdk:8
variables:
APP_VERSION: "1.1.10"
APP_NAME: 'ena-file-downloader'
FTP_DIR: "/nfs/ftp/public/databases/ena/tools"
APP_NAME_VERSION: ${APP_NAME}-${APP_VERSION}.zip
FTP_STG_DIR: "/nfs/production/cochrane/ena/ftp-staging/tools"
stages:
- test
- build
- deploy
cache:
paths:
- .gradle/wrapper
- .gradle/caches
test:
stage: test
before_script:
- export GRADLE_USER_HOME=.gradle
tags:
- dcap-gitlab-runner
script:
- chmod u+x gradlew
- ./gradlew clean test
build_prod:
stage: build
before_script:
- export GRADLE_USER_HOME=.gradle
script:
- ./gradlew clean build -x test
artifacts:
paths:
- build/dist/${APP_NAME_VERSION}
tags:
- dcap-gitlab-runner
only:
- master
deploy_prod:
stage: deploy
before_script:
# Setup SSH deploy keys
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$CODON_DATALIB_SSH_PVT_KEY")
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- chmod u+x build/dist/${APP_NAME_VERSION}
- scp -o StrictHostKeyChecking=no build/dist/${APP_NAME_VERSION} [email protected]:${FTP_STG_DIR}
- ssh [email protected] "sbatch --mem 1G -t 3:00:00 -p datamover -W --wrap=\"cd ${FTP_STG_DIR} && find . -type f -name 'ena-file-downloader-*' -not -name ${APP_NAME_VERSION} -delete\""
- ssh [email protected] "sbatch --mem 1G -t 3:00:00 -p datamover -W --wrap=\"rsync -avt --include=${APP_NAME_VERSION} --exclude=\"*\" --exclude=\"ena-file-downloader-*\" --delete-excluded ${FTP_STG_DIR}/ ${FTP_DIR}/\""
- ssh [email protected] "sbatch --mem 1G -t 3:00:00 -p datamover -W --wrap=\"cd ${FTP_DIR} && ln -sf ${APP_NAME_VERSION} ${APP_NAME}.zip\""
dependencies:
- build_prod
when: manual
tags:
- dcap-gitlab-runner
only:
- master