Files
mkdocs/docs/DevOps平台/Drone CI使用指南.md
2026-01-05 10:31:24 +08:00

80 lines
1.5 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.
# Drone CI 使用指南
## 简介
Drone 是一个基于容器的持续集成/持续部署CI/CD平台。
## 访问地址
- **Web 界面**: http://101.43.95.130:3000 (需配置)
## 基本概念
### Pipeline
Pipeline 是 CI/CD 的执行流程,定义在 `.drone.yml` 文件中。
### Step
Step 是 Pipeline 中的一个步骤,每个 Step 在一个独立的容器中执行。
### Service
Service 是 Pipeline 中提供的服务,如数据库、缓存等。
## 配置文件示例
在项目根目录创建 `.drone.yml`:
```yaml
kind: pipeline
type: docker
name: default
steps:
- name: build
image: maven:3.8-openjdk-17
commands:
- mvn clean package
- name: test
image: maven:3.8-openjdk-17
commands:
- mvn test
- name: deploy
image: alpine
commands:
- echo "部署应用..."
```
## 常用操作
### 触发构建
- 推送到仓库会自动触发构建
- 在 Web 界面手动触发构建
### 查看构建日志
在 Web 界面查看构建日志,了解构建过程。
### 构建状态
- **Success**: 构建成功
- **Failure**: 构建失败
- **Running**: 构建中
- **Pending**: 等待执行
## 最佳实践
1. **缓存依赖**: 使用缓存加速构建
2. **并行执行**: 将独立的任务并行执行
3. **环境变量**: 使用密钥管理敏感信息
4. **通知机制**: 配置构建通知
## 相关链接
- [Drone 官方文档](https://docs.drone.io/)