From d85cdb9b22a7549e553eba5672247c07fda4752d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 18:26:35 +0100 Subject: [PATCH] Added gitci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4095436 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,40 @@ +stages: + - build + - deploy + +build: + stage: build + image: java:14 + script: + - echo "Start building App" + - rm -rf restservice/src/main/resources/application.properties + - echo "spring.profiles.active=prod" > restservice/src/main/resources/application.properties + - mvn clean + - mvn install + - cd restservice + - mvn clean package spring-boot:repackage + - echo "Build successfully!" + artifacts: + expire_in: 1 hour + paths: + - restservice/target/ + +deploy_production: + stage: deploy + before_script: + - apt-get update + - apt-get --yes --force-yes install rsync + script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - ssh-add <(echo "$SSH_PRIVATE_KEY") + - mkdir -p ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + - echo "Deploying to server" + - ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl stop plannaplan-backend" + - rsync --progress target/*.jar --delete backend@wmi-backend-gc.plannaplan.pl:/opt/plannaplan-backend/backend.jar + - sleep 5 + - ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl start plannaplan-backend" + - echo "Deployed" + #only: + #- master