Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications

Categories

🎓 Certifications
🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
CheatGrid
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications
LVLEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

GitLab CI/CD Cheat Sheet

GitLab CI/CD Cheat Sheet

Back to DevOps
Updated 2026-04-28
Next Topic: GitOps Cheat Sheet

GitLab CI/CD is a built-in continuous integration and continuous deployment platform that automates the entire software development lifecycle — from building and testing code to deploying it to production. Unlike tools that require third-party plugins, GitLab CI/CD is natively integrated into GitLab, enabling teams to define workflows in a single .gitlab-ci.yml file at the repository root. Pipelines can run in Docker containers, on Kubernetes, or on bare-metal; support DAGs, parent-child relationships, and component-based reuse; and use CI/CD inputs for type-safe parameter passing as the modern replacement for plain variables. The key mental model: pipelines are composed of stages, stages contain jobs, and jobs execute scripts — with every aspect configurable through YAML keywords that control execution order, dependencies, caching, artifacts, and deployment strategies.


What This Cheat Sheet Covers

This topic spans 16 focused tables and 149 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core Pipeline StructureTable 2: Job Execution ControlTable 3: Artifacts and CachingTable 4: Docker and Container ConfigurationTable 5: Variables and SecretsTable 6: Environments and DeploymentsTable 7: Pipeline Types and TriggersTable 8: Advanced Job ConfigurationTable 9: Runner ConfigurationTable 10: Includes and TemplatesTable 11: Security ScanningTable 12: Pipeline Security PracticesTable 13: Review Apps and Preview EnvironmentsTable 14: Optimization StrategiesTable 15: Workflow PatternsTable 16: Debugging and Troubleshooting

Table 1: Core Pipeline Structure

These are the keywords you reach for first when writing any .gitlab-ci.yml — the scaffolding that turns a YAML file into a working pipeline. Get the relationship between stages, job, and script straight and everything else clicks into place, while default, include, extends, and the !reference tag are the levers that keep large configurations from drowning in duplication.

KeywordExampleDescription
stages
stages:
- build
- test
- deploy
• Defines the ordered sequence of stages
• jobs in the same stage run in parallel, stages execute sequentially.
job
build-app:
stage: build
script:
- npm run build
A named job in a specific stage — the fundamental unit of work in a pipeline.
script
script:
- echo "Building..."
- make build
• Required keyword defining shell commands to execute
• each line runs in sequence.
before_script
before_script:
- apt-get update
- apt-get install -y curl
• Commands that run before the main script
• commonly used for environment setup.
after_script
after_script:
- rm -rf /tmp/*
- cleanup.sh
• Commands that run after the main script completes (even on failure)
• used for cleanup.
default
default:
image: node:18
cache:
paths: [node_modules/]
• Sets default values for all jobs in the pipeline
• individual jobs can override.

More in DevOps

  • ELK and OpenSearch Stack Cheat Sheet
  • GitOps Cheat Sheet
  • AI-Powered DevOps Copilots and Agents Cheat Sheet
  • Configuration Drift Cheat Sheet
  • Immutable Infrastructure Cheat Sheet
  • Pulumi Programmatic IaC Cheat Sheet
View all 49 topics in DevOps