forked from LibreHealthIO/lh-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
45 lines (40 loc) · 1.65 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
image: maven:3-jdk-8
stages:
- build
- test
- deploy
unit_test-job:
stage: test
script:
- groupadd -g 900 ci
- useradd -d /builds -s /bin/bash -M -u 900 -g 900 -N ci
- chown -R ci:ci /builds
- su ci -c "mvn test -U"
build-job:
stage: build
script:
- groupadd -g 900 ci
- useradd -d /builds -s /bin/bash -M -u 900 -g 900 -N ci
- chown -R ci:ci /builds
- su ci -c "mvn package -U -DskipTests=true"
- mv webapp/target/openmrs.war webapp/target/lh-toolkit.war
#Delete first, then upload and publish
- curl -X DELETE -u$BINTRAY_API_USER:$BINTRAY_API_KEY https://api.bintray.com/content/librehealth/lh-toolkit-war/lh-toolkit.war
- curl -T webapp/target/lh-toolkit.war -u$BINTRAY_API_USER:$BINTRAY_API_KEY https://api.bintray.com/content/librehealth/lh-toolkit-war/lh-toolkit-devbuilds/latest/lh-toolkit.war
- curl -X POST -u$BINTRAY_API_USER:$BINTRAY_API_KEY https://api.bintray.com/content/librehealth/lh-toolkit-war/lh-toolkit-devbuilds/latest/publish
artifacts:
paths:
- webapp/target/*.war
expire_in: 5 days
deploy-job:
stage: deploy
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- apt-get update -y && apt-get install rsync -y
# run ssh-agent
- eval $(ssh-agent -s)
- mv webapp/target/lh-toolkit.war webapp/target/master.war
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress webapp/target/master.war [email protected]:/var/lib/tomcat8/webapps