How do artifacts and cache differ in GitLab CI?

IntermediateConceptGitLab CI
Answer

Artifacts are job outputs uploaded to GitLab, passed to later-stage jobs automatically (or selectively via dependencies/needs: artifacts) and downloadable from the UI; they expire (expire_in). Cache is stored by the runner (locally or in S3/GCS) to reuse dependencies between pipelines, keyed by cache:key, and is best-effort. Use cache:key:files: [package-lock.json] so the cache invalidates when the lockfile changes.

test:
  cache:
    key: { files: [package-lock.json] }
    paths: [.npm/]
  artifacts:
    when: always
    paths: [coverage/]
    reports: { junit: junit.xml }
    expire_in: 1 week
All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI