Files
nexus/wiki/concepts/CI-CD Pipeline.md
2026-05-03 05:42:12 +08:00

84 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "CI/CD Pipeline"
type: concept
tags: [DevOps, Automation, Software Delivery]
sources: [engineering-devops-automator]
last_updated: 2026-05-01
---
# CI/CD Pipeline
## 定义
CI/CD 流水线是自动化软件交付的端到端管道包含持续集成Continuous Integration、持续交付Continuous Delivery和持续部署Continuous Deployment三个阶段。
## 三个阶段
### 持续集成CI
- 开发者频繁提交代码到共享仓库
- 每次提交自动触发构建和测试
- 早期发现集成问题
### 持续交付CD
- 代码通过所有自动化测试后自动部署到 staging 环境
- 人工审批后部署到生产环境
- 确保每次变更都可部署
### 持续部署Continuous Deployment
- 代码通过所有测试后自动部署到生产环境
- 无需人工干预
- 需要完善的测试和监控体系支撑
## 核心组件
### 构建阶段
- 代码编译
- 依赖安装
- 制品构建Docker 镜像/二进制文件)
### 测试阶段
- 单元测试
- 集成测试
- 端到端测试
- 安全扫描
### 部署阶段
- 部署到目标环境
- 健康检查
- 流量切换
- 回滚机制
## DevOps Automator 的标准流水线
```yaml
security-scan → test → build → deploy
```
- security-scan依赖漏洞扫描 + 静态安全分析
- test单元测试 + 集成测试
- build容器构建 + 推送镜像仓库
- deploy零停机部署蓝绿/金丝雀/滚动)
## 相关工具
- [[GitHub Actions]]DevOps Automator 默认选择
- Jenkins开源 CI/CD 服务器
- GitLab CIGitLab 内置 CI/CD
- ArgoCDGitOps 持续交付
- Spinnaker多云持续交付平台
## 相关概念
- [[Infrastructure as Code]]CI/CD 部署目标通常是 IaC 管理的基础设施
- [[Zero-Downtime Deployment]]CI/CD 的部署策略
- [[Blue-Green Deployment]]CI/CD 常用部署策略
## 关键指标
- **部署频率**:每日部署次数
- **变更前置时间**:代码提交到生产的时间
- **变更失败率**:生产环境回滚或失败的百分比
- **MTTR**:平均恢复时间
## Aliases
- CI/CD
- CI/CD Pipeline
- 持续集成/持续交付
- Continuous Integration
- Continuous Delivery
- Continuous Deployment