-
Notifications
You must be signed in to change notification settings - Fork 14
/
.gitlab-ci.yml
65 lines (57 loc) · 2.05 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: maven:3-jdk-8
stages:
- test
- publish
- deploy
- publish-docker
unit-test-job:
image: maven:3.3.9-jdk-8
stage: test
script:
- mvn package -B
artifacts:
paths:
- webapp/target/*.war
expire_in: 5 days
publish-job:
stage: publish
script:
- 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
publish-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/tomcat9/webapps
docker-build-master:
image: docker:latest
stage: publish-docker
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
docker-build:
image: docker:latest
stage: publish-docker
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- master