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 1/7] 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 From 9f3e41e6016617cc02ef503ae1d7b8020db2d2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 18:31:07 +0100 Subject: [PATCH 2/7] Updated .git-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4095436..9bae65e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: build: stage: build - image: java:14 + image: openjdk14 script: - echo "Start building App" - rm -rf restservice/src/main/resources/application.properties @@ -18,7 +18,7 @@ build: expire_in: 1 hour paths: - restservice/target/ - + deploy_production: stage: deploy before_script: From 0c471162f22b841fd9830321ad3ade1c0bbffe08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 18:31:58 +0100 Subject: [PATCH 3/7] Updated .git-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9bae65e..9781098 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: build: stage: build - image: openjdk14 + image: adoptopenjdk/openjdk14 script: - echo "Start building App" - rm -rf restservice/src/main/resources/application.properties From 086e4be4581f539cc3af40a986c4c12579453330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 18:37:02 +0100 Subject: [PATCH 4/7] Updated .git-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9781098..6f485fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: build: stage: build - image: adoptopenjdk/openjdk14 + image: maven script: - echo "Start building App" - rm -rf restservice/src/main/resources/application.properties From b495fd7f65ebab3f5fa7abb2519a29c194a7a5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 18:41:08 +0100 Subject: [PATCH 5/7] Updated .git-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f485fc..c8d3ec0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,8 @@ deploy_production: - '[[ -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 + - ssh backend@wmi-backend-gc.plannaplan.pl -t "rm -rf /opt/plannaplan-backend/backend.jar" + - rsync --progress target/*.jar 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" From 181d93082c7d672fb08a11719f5a3a6a94b09659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 18:42:18 +0100 Subject: [PATCH 6/7] Updated .git-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8d3ec0..fa40c22 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,7 @@ deploy_production: - echo "Deploying to server" - ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl stop plannaplan-backend" - ssh backend@wmi-backend-gc.plannaplan.pl -t "rm -rf /opt/plannaplan-backend/backend.jar" - - rsync --progress target/*.jar backend@wmi-backend-gc.plannaplan.pl:/opt/plannaplan-backend/backend.jar + - rsync --progress restservice/target/*.jar 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" From 2921c98c354b6f9c26a0c5dfd9ad336e7ef4e785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Tue, 8 Dec 2020 19:02:02 +0100 Subject: [PATCH 7/7] Updated .git-ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa40c22..a31a8d0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,5 +37,5 @@ deploy_production: - sleep 5 - ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl start plannaplan-backend" - echo "Deployed" - #only: - #- master + only: + - master