Anything you do to GitLab CI/CD twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.
1. Install it reproducibly
# Register a self-managed runner (Docker executor)
gitlab-runner register --url https://gitlab.com \
--registration-token $TOKEN --executor docker --docker-image alpine:32. Describe the desired state
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"' }]3. Run it from CI
Reuse shared pipeline logic with include.
include:
- project: acme/ci-templates
file: /templates/node.yml
- template: Security/SAST.gitlab-ci.ymlWant 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.