Most GitLab CI/CD pain is self-inflicted and predictable. Here are the mistakes we see most, and the fix for each.
Mistake 1: Everything in one stage, so nothing runs in parallel
Fix: Use stages and needs: for a fast DAG pipeline. Make it the default in your templates and enforce it in review or CI so the mistake cannot come back.
Mistake 2: No cache/artifacts config, re-downloading dependencies every job
Fix: Cache dependencies and pass build output as artifacts. Make it the default in your templates and enforce it in review or CI so the mistake cannot come back.
Mistake 3: Secrets in .gitlab-ci.yml instead of masked/protected CI variables
Fix: Store secrets as masked, protected CI/CD variables. Make it the default in your templates and enforce it in review or CI so the mistake cannot come back.
A safer baseline
Stages, caching and a manual production gate.
stages: [build, test, deploy]
cache: { paths: [node_modules/] }
build:
stage: build
image: node:20
script: [npm ci, npm run build]
test:
stage: test
image: node:20
script: [npm test]
deploy:prod:
stage: deploy
script: [./deploy.sh]
environment: { name: production }
when: manual
rules: [{ if: '$CI_COMMIT_BRANCH == "main"' }]Want senior help putting GitLab CI/CD to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.