Gitlab Cicd Pipeline

aj-geddes/useful-ai-prompts/skills/gitlab-cicd-pipeline

作者 aj-geddes3f5182cfd739无许可证355 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Design and implement GitLab CI/CD pipelines with stages, jobs, artifacts, and caching. Configure runners, Docker integration, and deployment strategies.

包含脚本DevOps & Cloud
AI 生成的概览

设计 GitLab CI/CD 流水线,涵盖阶段、作业、缓存、Runner、Docker 与 Kubernetes 部署。

功能
提供构建 GitLab CI/CD 流水线的指导与参考资料,涵盖阶段、作业、制品、缓存、Runner 配置、Docker 层缓存、多项目流水线以及 Kubernetes 部署。包含一个最小的 .gitlab-ci.yml 示例、一个流水线模板和一个校验脚本。交付物是流水线配置与部署方案,而非应用代码。
适用场景
适用于为 GitLab 仓库搭建或改进 CI/CD 的场景,包括多阶段构建、Docker 镜像仓库集成、Review App 或 Kubernetes 部署,以及缓存优化。
运行要求
需要具备 CI/CD 的 GitLab 仓库与 GitLab Runner 基础设施;容器与部署步骤需要 Docker 和 Kubernetes 访问权限。附带可执行校验脚本和流水线模板。

GitLab CI/CD Pipeline

Table of Contents

Overview

Create comprehensive GitLab CI/CD pipelines that automate building, testing, and deployment using GitLab Runner infrastructure and container execution.

When to Use

  • GitLab repository CI/CD setup
  • Multi-stage build pipelines
  • Docker registry integration
  • Kubernetes deployment
  • Review app deployment
  • Cache optimization
  • Dependency management

Quick Start

Minimal working example:

yaml
# .gitlab-ci.ymlimage: node:18-alpine
variables:  DOCKER_DRIVER: overlay2  FF_USE_FASTZIP: "true"
stages:  - lint  - test  - build  - security  - deploy-review  - deploy-prod
cache:  key: ${CI_COMMIT_REF_SLUG}  paths:    - node_modules/    - .npm/
lint:  stage: lint  script:    - npm install// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Complete Pipeline Configuration [blocked]Complete Pipeline Configuration
GitLab Runner Configuration [blocked]GitLab Runner Configuration
Docker Layer Caching Optimization [blocked]Docker Layer Caching Optimization
Multi-Project Pipeline [blocked]Multi-Project Pipeline
Kubernetes Deployment [blocked]Kubernetes Deployment, Performance Testing Stage, Release Pipeline with Semantic Versioning

Best Practices

✅ DO

  • Use stages to organize pipeline flow
  • Implement caching for dependencies
  • Use artifacts for test reports
  • Set appropriate cache keys
  • Implement conditional execution with only and except
  • Use needs: for job dependencies
  • Clean up artifacts with expire_in
  • Use Docker for consistent environments
  • Implement security scanning stages
  • Set resource limits for jobs
  • Use merge request pipelines

❌ DON'T

  • Run tests serially when parallelizable
  • Cache everything unnecessarily
  • Leave large artifacts indefinitely
  • Store secrets in configuration files
  • Run privileged Docker without necessity
  • Skip security scanning
  • Ignore pipeline failures
  • Use only: [main] without proper controls

来源与署名

来源:aj-geddes/useful-ai-prompts位于skills/gitlab-cicd-pipeline提交3f5182c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架