Sign inSign up free

812. GitLab CI Cache vs Artifacts

medium 20 XP ~10 minHands-on lab

In /home/student/repos/storefront/.gitlab-ci.yml the test job fails with dist/ not found, and each job spends three minutes downloading the same npm packages.

Task

  • build keeps dist/ as an artifact that expires after 1 week, and test receives build's artifacts.
  • Both jobs use a cache of the .npm/ directory whose key is computed from package-lock.json (so it changes whenever the lockfile changes).
  • Only build uploads the cache: test only pulls it.
  • Every npm ci uses that cache: npm ci --cache .npm --prefer-offline.

Keep the test command as it is.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of CI/CD Pipelines in Practice. Next step: Manual Production Deploys in GitLab CI

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.