GitLab CI/CD 1 cheatsheet
GitLab CI/CD 1: Caching, artifacts and ordering
6 common GitLab CI/CD 1 tasks.
Cache dependencies
Reuse downloaded packages between pipelines. The key changes when the lock file does.
test-job:
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
Pass files to later jobs
Keep build output so later jobs and people can download it.
build-job:
script:
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 week
Start a job as soon as dependencies finish
Skip waiting for the whole previous stage.
test-job:
needs:
- build-job
Run a job for several versions
Create one job per variable combination.
test-job:
parallel:
matrix:
- NODE_VERSION: ["22", "24"]
image: node:$NODE_VERSION
script:
- npm test
Start a database for tests
Run a service container beside the job.
test-job:
services:
- postgres:18
variables:
POSTGRES_PASSWORD: postgres
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
Show test results in merge requests
Upload a JUnit report so failures show up in the merge request.
test-job:
script:
- npm test
artifacts:
when: always
reports:
junit: junit.xml