Develop and troubleshoot GitLab CI/CD pipelines. Use when creating pipeline YAML files, debugging job failures, understanding GitLab-specific features like DAG, rules, and includes, or optimizing pipeline performance.
Instrucciones de origen · Vista previa de solo lectura
name
cicd-gitlab-pipelines-dev
description
Develop and troubleshoot GitLab CI/CD pipelines. Use when creating pipeline YAML files, debugging job failures, understanding GitLab-specific features like DAG, rules, and includes, or optimizing pipeline performance.
GitLab CI/CD Pipeline Development
Guide for developing, debugging, and optimizing GitLab CI/CD pipelines.
When to Use This Skill
Creating new GitLab CI/CD pipelines
Debugging job failures from pipeline logs
Understanding GitLab-specific pipeline features
Optimizing pipeline performance and costs
Configuring runners and environments
Working with includes, extends, and templates
Pipeline Structure
File Location
Pipelines are defined in .gitlab-ci.yml at the repository root.
# Global variablesvariables:DATABASE_URL:"postgres://localhost/test"RAILS_ENV:test# Job-level variablestest:variables:COVERAGE:"true"script:-echo$COVERAGE
Use needs for faster pipelines by skipping stage ordering:
stages:-build-test-deploybuild-frontend:stage:buildscript:npmrunbuild:frontendbuild-backend:stage:buildscript:npmrunbuild:backendtest-frontend:stage:testneeds: [build-frontend] # Runs as soon as build-frontend completesscript:npmruntest:frontendtest-backend:stage:testneeds: [build-backend]
script:npmruntest:backenddeploy:stage:deployneeds: [test-frontend, test-backend]
script:./deploy.sh
Caching
cache:key:${CI_COMMIT_REF_SLUG}paths:-node_modules/-.npm/# Or per-job cachetest:cache:key:files:-package-lock.jsonpaths:-node_modules/script:-npmci--cache.npm-npmtest
include:# Local file-local:'/templates/.gitlab-ci-template.yml'# From another project-project:'my-group/ci-templates'ref:mainfile:'/templates/nodejs.yml'# Remote URL-remote:'https://example.com/templates/ci.yml'# GitLab templates-template:Auto-DevOps.gitlab-ci.yml
# Use needs for DAG# Use rules to skip unnecessary jobs# Cache aggressively# Use slim images# Parallelize where possibletest:parallel:4# Split tests across 4 jobsscript:-npmruntest----shard=$CI_NODE_INDEX/$CI_NODE_TOTAL