我有一个使用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/
在构建和页面作业之前,执行npm install命令(在每个作业之前执行一次).由于我有很多包,这通常需要一段时间.
有没有办法只在整个构建中进行一次安装?
我认为这是缓存应该有用的东西,但它似乎仍然会重新下载所有东西.
解决方法
虽然评论中的答案基本上是正确的.我认为你的案件的具体答案会很好.您可以使用的一种方法是添加第三个阶段,它将承担安装节点模块的负担,您还可以缓存它们以加速后续构建:
image: node:latest stages: - prep - build - deploy before_script: - npm install gulp-cli -g prep: stage: prep script: - npm install gulp [...and a whole bunch of packages] --save-dev artifacts: paths: - node_modules cache: paths: - node_modules build: stage: build script: - gulp buildsite artifacts: paths: - public pages: stage: deploy script: - gulp artifacts: paths: - public
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。