【问题标题】:Gitlab CI does not retain node_modules of other directory between jobsGitlab CI不保留作业之间其他目录的node_modules
【发布时间】:2019-03-31 22:38:05
【问题描述】:

我想使用 Gitlab CI 触发存储在一个存储库中的 Express API 和 React 应用程序的持续部署。我正在使用 shell 执行器。

这是我的目录结构

/server
/client
.gitlab-ci.yml

我的配置如下所示:

stages:
  - deploy

server:
  stage: deploy
  script: 
    - npm run start
    - forever restartall
  only:
    refs: 
      - staging
    changes:
      - server/

client:
  script: 
    - npm run build --prefix ./client
  stage: deploy
  only:
    refs: 
      - staging
    changes:
      - client/

但是当客户端作业运行时,它会清除服务器文件夹的 node_modules 导致服务器崩溃。

我想要一种保留 node_modules 的方式。或者我可以使用 Gitlab CI/CD 一起构建服务器和客户端的任何其他方式

【问题讨论】:

    标签: gitlab gitlab-ci-runner


    【解决方案1】:

    您需要定义每个阶段要保留的文件夹:

    server:
      stage: deploy
      script:
         - ....
     artifacts:
        paths:
            - node_modules/
            - bower/
            - ....
    

    所有文物将从一个阶段转移到另一个阶段。更多信息请见https://docs.gitlab.com/ee/ci/yaml/#artifacts

    【讨论】:

      猜你喜欢
      • 2016-12-16
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 2018-10-03
      • 2017-09-30
      • 2018-06-05
      • 1970-01-01
      相关资源
      最近更新 更多