stages: # List of stages for jobs, and their order of execution - pre-build - build - deploy pre-build-job: stage: pre-build script: - rm -rf /home/gitlab-runner/uthmeta-temp/ - mkdir -p /home/gitlab-runner/uthmeta-temp/ build-job: # This job runs in the build stage, which runs first. stage: build script: - echo "packaging jar package." - cd java/ - mvn package '-Dmaven.test.skip=true' - cp ./nft-admin/target/nft-admin.jar /home/gitlab-runner/uthmeta-temp/ - cp ./nft-api/target/nft-api.jar /home/gitlab-runner/uthmeta-temp/ - echo "package complete." deploy-job: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. script: - echo "Deploying application..." - cd java - scp -r /home/gitlab-runner/uthmeta-temp/*.jar root@10.0.0.20:/root/uthmeta/ - ssh -l root 10.0.0.20 "sh /root/uthmeta/deploy.sh" - echo "Application successfully deployed."