GitLab CI/CD Pipelines

Overview

GitLab CI/CD automates build, test, security checks, and deployments using .gitlab-ci.yml pipeline definitions.

Pipeline Structure

flowchart TD A[Build] --> B[Test] B --> C[Security Scan] C --> D[Deploy]

Practical Example

stages: [build, test, deploy] build: stage: build script: - npm ci - npm run build test: stage: test script: - npm test deploy: stage: deploy script: - ./scripts/deploy.sh rules: - if: '$CI_COMMIT_BRANCH == "main"'

Production Example

Teams commonly use protected environments and manual approvals for production jobs while keeping lower environments fully automated.

Common Pitfalls

Key Takeaways