1

We use GitLab CI for our project. Our build stage is currently taking close to 13 minutes to complete because node_modules are always removed, downloaded & npm installed again. Also the node_modules is quite big (close to 200 MB). We've already set the cache in our .gitlab-ci.yaml file but that doesn't seem to work. Here's how we've set it to :

cache:
  key: $CI_PROJECT_PATH_SLUG
  untracked: true
  paths:
    - project/node_modules/
  policy: pull

If we set it to cache on a project level why isn't it performing as intended?

Other solutions posted here didn't work for us. All ideas for improving the cache mechanism & reducing build time are welcome.

YoganA
  • 41
  • 4
  • No didn't try with artifacts . Aren't dependencies not to be used as artifacts? I strictly followed [gitlab's documentation](https://docs.gitlab.com/ee/ci/caching/) & it clearly said things like node dependencies can be cached using the `cache` method. – YoganA May 24 '20 at 05:35
  • When you say you set it to cache on a project level. Do you mean that the snippet you pasted here is set globally for all the jobs of your pipeline? – jphuynh May 24 '20 at 15:50
  • @jphuynh Yes that was our intention. Since we have 3 environments & when a change is triggered the build should happen using the `cache` so that time isn't wasted on downloading them from the internet every time. – YoganA May 25 '20 at 01:13
  • It's a bit difficult to see without the full gitlab-ci.yml file but unless you also override the cache settings in the job that needs to populate it, `policy: pull` will prevent the cache from being pushed. – jphuynh May 25 '20 at 12:11

0 Answers0