1. stages: # 分段
    2. - deploy-sit
    3. - deploy-prod
    4. cache: # 缓存
    5. paths:
    6. - node_modules
    7. before_script:
    8. - sshpass -p $PASSWORD ssh $USERNAME@$IP -o StrictHostKeyChecking=no
    9. - cd ~
    10. - ([ -d /root/backend-cicd/app/public ] && mv /root/backend-cicd/app/public /root/public) || echo
    11. - rm -rf ./backend-cicd
    12. - git clone git@192.168.235.129:zhongs/backend-cicd.git
    13. - ([ -d /root/public ] && mv /root/public /root/backend-cicd/app/public) || echo
    14. - cd ./backend-cicd
    15. deploy-sit-job:
    16. tags:
    17. - backend-cicd
    18. only:
    19. - sit
    20. stage: deploy-sit
    21. script:
    22. - pwd
    23. - git checkout sit
    24. - cnpm install
    25. - npm run stop
    26. - npm run start-sit
    27. - exit
    28. deploy-prod-job:
    29. tags:
    30. - backend-cicd
    31. only:
    32. - prod
    33. stage: deploy-prod
    34. script:
    35. - pwd
    36. - git checkout prod
    37. - cnpm install
    38. - npm run stop
    39. - npm run start-prod
    40. - exit