.gitlab-ci.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # 定义 stages(阶段)。任务将按此顺序执行。
  2. stages:
  3. - build
  4. - test
  5. - deploy
  6. # 定义 job
  7. job1:
  8. stage: build #如果此处没有定义stage,其默认也是test
  9. only:
  10. - master
  11. tags:
  12. - ruoyi-train
  13. script:
  14. - echo "I am stopping train and removing jar"
  15. - sudo sh /mnt/prod/train_deploy.sh stop train-
  16. - sudo rm -rf /mnt/prod/*.jar
  17. job2:
  18. stage: build #如果此处没有定义stage,其默认也是test1
  19. only:
  20. - master
  21. tags:
  22. - ruoyi-train
  23. script:
  24. - echo "I am maven generate"
  25. - cd /home/gitlab-runner/builds/f1c93ad9/0/hellevil/train-cloud
  26. - mvn clean install
  27. # 定义 job(任务)
  28. job3:
  29. stage: test
  30. only:
  31. - master
  32. tags:
  33. - ruoyi-train
  34. script:
  35. - sudo mv /home/gitlab-runner/builds/f1c93ad9/0/hellevil/train-cloud/ruoyi-modules/train-resource/target/train-resource.jar /mnt/prod/train-resource.jar
  36. - sudo mv /home/gitlab-runner/builds/f1c93ad9/0/hellevil/train-cloud/ruoyi-modules/train-community/target/train-community.jar /mnt/prod/train-community.jar
  37. - sudo mv /home/gitlab-runner/builds/f1c93ad9/0/hellevil/train-cloud/ruoyi-modules/train-education/target/train-education.jar /mnt/prod/train-education.jar
  38. # 定义 job
  39. job4:
  40. stage: deploy
  41. only:
  42. - master
  43. tags:
  44. - ruoyi-train
  45. script:
  46. - nohup java -jar /mnt/prod/train-resource.jar >/mnt/prod/train-resource.jar.out &
  47. - sleep 5
  48. - nohup java -jar /mnt/prod/train-community.jar >/mnt/prod/train-community.jar.out &
  49. - sleep 5
  50. - nohup java -jar /mnt/prod/train-education.jar >/mnt/prod/train-education.jar.out &
  51. - sleep 5
  52. - echo "all jars have been startup"