Run install, test, and build using stages.

Section: Pipeline building blocks

Minimal GitLab CI pipeline

yaml
yaml
stages:
  - test
  - build

default:
  image: node:20

cache:
  paths:
    - node_modules/

test:
  stage: test
  script:
    - npm ci
    - npm test

build:
  stage: build
  script:
    - npm ci
    - npm run build
Explanation

GitLab pipelines are defined in `.gitlab-ci.yml` and usually organized with `stages` and jobs.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Pipeline building blocks
Minimal GitHub Actions pipeline
Build and test on pushes and pull requests.
OpenIn sheetyamlsame section
Minimal Jenkins declarative pipeline
Run checkout, install, test, and build in a Jenkinsfile.
OpenIn sheetgroovysame section
Validate pull requests only
Run CI before code reaches main.
Deploy only from main
Restrict production deployment to your protected main branch.
Nightly scheduled workflow
Run audits, backups, smoke tests, or dependency checks on a schedule.