1. stages: # 分段
    2. - install
    3. - build
    4. - deploy-sit
    5. - deploy-prod
    6. cache: # 缓存
    7. paths:
    8. - node_modules
    9. - dist
    10. install-job:
    11. tags:
    12. - sit
    13. only:
    14. - sit
    15. - prod
    16. stage: install
    17. script:
    18. - cnpm install
    19. build-job:
    20. tags:
    21. - sit
    22. only:
    23. - sit
    24. - prod
    25. stage: build
    26. script:
    27. - npm run build
    28. deploy-sit-job:
    29. tags:
    30. - sit
    31. only:
    32. - sit
    33. stage: deploy-sit
    34. script:
    35. - sshpass -p $PASSWORD scp -r ./dist/* $USER_NAME@$IP:/root/backend-cicd/app/public
    36. deploy-prod-job:
    37. tags:
    38. - sit
    39. only:
    40. - prod
    41. stage: deploy-prod
    42. script:
    43. - sshpass -p $PASSWORD scp -r ./dist/* $USER_NAME@$IP:/root/backend-cicd/app/public