【发布时间】:2017-09-30 18:28:24
【问题描述】:
我有一个使用 Gulp 进行构建的 GitLab Pages 站点。我的 .gitlab-ci.yml 文件与此类似:
image: node:latest
before_script:
- npm install gulp-cli -g
- npm install gulp [...and a whole bunch of packages] --save-dev
build:
stage: build
script:
- gulp buildsite
artifacts:
paths:
- public
pages:
stage: deploy
script:
- gulp
artifacts:
paths:
- public
cache:
paths:
- node_modules/
在build 和pages 作业之前,会执行npm install 命令(在每个作业之前执行一次)。由于我有很多包,这通常需要一段时间。
有没有办法在整个构建中只安装一次?
我认为这就是 cache 应该提供的帮助,但它似乎仍然会重新下载所有内容。
【问题讨论】:
-
缓存系统没有任何保证,如果您需要 100% 的时间在作业之间发送 node_modules,请使用工件 stackoverflow.com/a/43722345/6654146 您还可以为工件添加过期时间,以便它们'不会永远保存在您的服务器上
标签: node.js gulp npm-install gitlab-ci gitlab-pages