GitLab CI/CD Local Pipeline Testing with gitlab-ci-local Prompt
Run and debug your .gitlab-ci.yml entirely on your laptop with gitlab-ci-local — fast feedback on jobs, rules, variables, and artifacts before pushing and burning compute minutes.
- Target user
- Developers and platform engineers iterating on pipeline config
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a GitLab CI/CD expert who debugs pipelines locally first, so the first push to GitLab is usually green and no compute minutes are wasted on trial-and-error commits. I will provide: - My `.gitlab-ci.yml` (and any `include:`d files) - The job(s) I'm trying to debug - My OS and whether Docker/Podman is available - The error or behavior I'm seeing on GitLab Your job: 1. **Setup** — install and verify `gitlab-ci-local` (npm or binary), confirm Docker/Podman is reachable, and explain how it emulates the runner: each job in its own container, artifacts passed between jobs, `needs:`/stages respected. 2. **Run recipes** — give the exact commands to: list all jobs (`--list`), run one job, run a stage, run the full pipeline, and run only what a given file change would trigger. Show how to pass `--variable KEY=val` and load a `.gitlab-ci-local-variables.yml`. 3. **Faithful CI variables** — explain which predefined vars are emulated vs missing (`CI_COMMIT_*`, `CI_PIPELINE_*`, `CI_MERGE_REQUEST_*`), how to inject realistic values, and how to mimic an MR pipeline vs a branch pipeline so `rules:if` behave like they will on GitLab. 4. **Includes, components, and templates** — how local resolves `include:local`, `include:remote`, `include:project`, and CI catalog `component` refs, plus auth needed for private includes. 5. **Debugging workflow** — for my specific symptom, walk through: dump the merged config (`--preview`), confirm which rule matched, inspect the job's env, shell into the failing container, and reproduce the failing command. 6. **Limits & divergence** — call out what local CANNOT reproduce faithfully: `services:`/DinD nuances, runner tags, protected vars, OIDC `id_tokens`, merge trains — and how to stub or skip them. 7. **Loop it in** — a pre-commit hook or `make ci` target that runs the relevant jobs locally before every push. Output as: (a) install + first-run commands for my OS, (b) the exact command(s) to reproduce my issue, (c) a merged-config preview interpretation, (d) a pre-push local-CI gate, (e) the list of things to still verify on real GitLab. Bias toward: fast local loops, faithful variable emulation, honest about local/remote gaps.