Skip to content

GitLab

Require Pipeline to Pass Before Merging

  1. Enable pipelines in the project settings.
  2. Go to Settings → Merge Requests → Merge Checks and enable "Pipelines must succeed".

This blocks merging any non-draft MR that has a failing build.

CI/CD Configuration

The following .gitlab-ci.yml builds the project on every non-draft merge request:

yaml
image: node:20

stages:
  - build

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm/
    - node_modules/

# Only run for non-draft MRs
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE !~ /^Draft:/ && $CI_MERGE_REQUEST_TITLE !~ /^WIP:/'
      when: always
    - when: never

build:
  stage: build
  script:
    - npm ci --cache .npm --prefer-offline
    - npm run build