GitLab CI/CD Generator
Generate .gitlab-ci.yml configuration files with stages, jobs, caching, artifacts, and deployment.
What is GitLab CI/CD?
GitLab CI/CD is a continuous integration and continuous delivery platform built into GitLab. Pipelines are defined using a .gitlab-ci.yml file placed in the root of your repository. That single file declares the stages a pipeline runs, the jobs inside each stage, the commands each job executes, and the conditions under which jobs run.
When you push to GitLab, it reads the file and hands each job to a GitLab Runner, an agent that executes the job inside a container. Shared runners are available on GitLab.com with usage limits, or you can install self-managed runners on your own infrastructure. Because jobs run in containers, the image: key selects the exact toolchain for a job, so a PHP job and a Node.js job can each get an appropriate environment.
This generator creates production-ready configurations for common languages and frameworks. The generated YAML follows GitLab conventions including dependency caching, artifact handling, a manual deployment gate, and optional review-app environments.
How the pipeline is structured
- stages — an ordered list. All jobs in a stage finish before the next stage begins, so a failing test blocks the build.
- jobs — named blocks such as
lint:,test:, andbuild:. Each job declares a stage and a script. - before_script — commands that run before every job, typically installing dependencies.
- cache — persists directories such as
node_modules/orvendor/between pipelines to speed up installs. - artifacts — files produced by a job that are kept and can be passed to later stages.
- environment — ties a deploy job to a named environment such as production or a review app.
The test stage is always included, since a pipeline without tests is rarely useful. Lint, build, and deploy are optional toggles.
How to Use
- Select Language — Choose your project language or framework from the dropdown.
- Configure Stages — Toggle which CI/CD stages to include: lint, test, build, and/or deploy.
- Set Options — Enable caching, artifacts, review apps, and set the deployment branch.
- Copy or Download — Use the copy button or download the
.gitlab-ci.ymlfile and place it in your project root.
Stages and default commands
Each stage runs a language-appropriate command. The table below shows what the generator emits for the npm/Node.js and PHP examples; other languages follow the same pattern with their own toolchain.
| Stage | Node.js | PHP / Laravel |
|---|---|---|
| before_script | npm ci | composer install |
| lint | npm run lint | phpcs --standard=PSR12 |
| test | npm test | phpunit |
| build | npm run build | build via Docker |
| cache path | node_modules/ | vendor/ |
Go caches .go-cache/ and Rust caches target/. Python and Docker configurations do not emit a cache block by default.
Example generated pipeline
For a Node.js project with lint, test, and build enabled, caching on, and a manual deploy, the generator produces something like this (abridged):
stages:
- lint
- test
- build
- deploy
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
before_script:
- npm ci --cache .npm --prefer-offline
test:
stage: test
image: node:22
script:
- npm test
deploy:
stage: deploy
image: alpine:latest
script:
- echo "Add your deploy commands here"
environment:
name: production
only:
- main
when: manual
Deployment is deliberately gated with when: manual and restricted to a single branch, so a merge never ships to production without a deliberate click.
Common use cases
- Migrating to GitLab — bootstrap a pipeline when moving a project from another CI provider.
- Standardising team pipelines — generate a consistent baseline across many repositories.
- Adding caching — cut pipeline time by caching dependency directories between runs.
- Review apps — spin up a throwaway environment per merge request and tear it down automatically.
- Learning the format — see a working, conventional
.gitlab-ci.ymlto adapt.
Frequently Asked Questions
Where should I place the generated file?
Place the .gitlab-ci.yml file in the root directory of your GitLab repository. GitLab automatically detects this file and runs the pipeline on every push.
What is a GitLab Runner and do I need one?
GitLab Runners are agents that execute CI/CD jobs. GitLab provides shared runners for free (with limits), or you can install your own. The generated configuration uses the docker executor, which works with both shared and self-managed runners.
Can I customize the generated pipeline further?
Yes. The generated YAML is a solid starting point. You can edit it to add custom scripts, environment variables, secrets, parallel jobs, matrix builds, or deployment targets specific to your project.
Why is the test stage always included?
A pipeline that builds and deploys but never tests offers little safety, so the test stage is always emitted. You can still remove it by editing the YAML if your workflow genuinely does not need it.
How does caching work in the generated file?
When caching is enabled the pipeline stores a language-specific directory — node_modules/ for Node.js, vendor/ for PHP, .go-cache/ for Go, and target/ for Rust — keyed by the branch slug. Later pipelines restore it to skip re-downloading dependencies.
What are artifacts used for?
Artifacts are files a job produces that GitLab keeps after the job finishes. They can be downloaded from the pipeline page and passed to later stages, and they expire after the configured period (one hour in the generated file).
How does deployment stay safe?
The deploy job uses when: manual and only: [branch], so it runs only on the branch you specify and only when someone clicks to start it. This prevents every push from immediately shipping to production.
What are review apps?
When enabled, review apps attach a temporary environment to each merge request and add a stop_review job that runs manually to tear it down. This gives reviewers a live URL for the change before it is merged.