Jor*_*Jor 14 node.js npm gitlab gitlab-ci npm-install
我正在使用GitLab CI进行项目,该过程的第一步是npm install.我node_modules稍后缓存以便更快地运行相同的作业,并将它们定义为构建工件,以便在后续阶段使用它们.但是,即使我缓存node_modules并且它是最新的,npm install每次install_packages运行作业时调用都需要很长时间,因为命令会遍历所有package.json并检查包的更新等(我假设).
根据某些条件,有没有办法只npm install在install_packages工作中运行?更具体地说(我认为这是最好的解决方案),package.json自上次构建以来是否已经改变了?
以下是我的.gitlab-ci.yml文件的相关部分:
image: node:6.9.1
stages:
- install
- prepare
- deploy
install_packages:
stage: install
script:
- npm prune
- npm install
cache:
key: ${CI_BUILD_REF_NAME}
paths:
- node_modules/
artifacts:
paths:
- node_modules/
only:
- master
- develop
build_and_test:
stage: prepare
script:
#do_stuff...
deploy_production:
stage: deploy
#do_stuff...
deploy_staging:
stage: deploy
#do_stuff...
Run Code Online (Sandbox Code Playgroud)
只需使用only:changes标志文档
该工作将是:
install_packages:
stage: install
script:
- npm prune
- npm install
cache:
key: ${CI_COMMIT_REF_NAME}
paths:
- node_modules/
artifacts:
paths:
- node_modules/
only:
refs:
- master
- develop
changes:
- package.json
Run Code Online (Sandbox Code Playgroud)
还有一点是:你设置缓存的方式正确吗?阅读此内容: https: //docs.gitlab.com/runner/configuration/autoscale.html#distributed-runners-caching https://docs.gitlab.com/ee/ci/caching/
| 归档时间: |
|
| 查看次数: |
3559 次 |
| 最近记录: |