addproject
This commit is contained in:
84
zhyy/test_case/README_JENKINS.md
Normal file
84
zhyy/test_case/README_JENKINS.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Jenkins + Allure 集成快速参考
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 安装Allure插件
|
||||
- Jenkins → Manage Jenkins → Manage Plugins
|
||||
- 搜索 "Allure Plugin" 并安装
|
||||
|
||||
### 2. 配置Allure工具
|
||||
- Manage Jenkins → Global Tool Configuration
|
||||
- Allure Commandline → 添加Allure安装路径
|
||||
|
||||
### 3. 创建Jenkins任务
|
||||
|
||||
#### 方式A:使用Jenkinsfile(推荐)
|
||||
1. 新建Pipeline任务
|
||||
2. Pipeline script from SCM
|
||||
3. Script Path: `zhyy/test_case/Jenkinsfile`
|
||||
4. 保存并运行
|
||||
|
||||
#### 方式B:自由风格项目
|
||||
1. 新建Freestyle project
|
||||
2. 构建步骤:执行 `jenkins_build.sh` 或 `jenkins_build.bat`
|
||||
3. Post-build Actions → Allure Report
|
||||
4. Results path: `zhyy/test_case/reports/allure-results`
|
||||
|
||||
## 参数化构建
|
||||
|
||||
在Jenkins任务中配置以下参数:
|
||||
|
||||
| 参数名 | 类型 | 说明 | 示例值 |
|
||||
|--------|------|------|--------|
|
||||
| RUN_TYPE | Choice | 运行方式 | all, feature, story, dir, file, keyword, marker |
|
||||
| FEATURE_NAME | String | Feature标签 | 深圳采购工作台采购订单页面 |
|
||||
| STORY_NAME | String | Story标签 | 验证采购工作台采购订单页面列表查询 |
|
||||
| DIR_PATH | String | 目录路径 | 接口/SZPurchase |
|
||||
| FILE_PATH | String | 文件路径 | 接口/SZPurchase/PurchaseOrderManage.py |
|
||||
| KEYWORD | String | 关键字 | purchase |
|
||||
| MARKER | String | Pytest标记 | smoke |
|
||||
|
||||
## 常用命令
|
||||
|
||||
### 本地运行
|
||||
```bash
|
||||
# 运行所有测试
|
||||
python run_tests.py
|
||||
|
||||
# 按目录运行
|
||||
python run_tests.py --dir "接口/SZPurchase"
|
||||
|
||||
# 按文件运行
|
||||
python run_tests.py --file "接口/SZPurchase/PurchaseOrderManage.py"
|
||||
|
||||
# 生成并打开报告
|
||||
python run_tests.py --all --report --open
|
||||
```
|
||||
|
||||
### Jenkins中运行
|
||||
```bash
|
||||
# 使用构建脚本(自动检测参数)
|
||||
bash jenkins_build.sh
|
||||
|
||||
# 或直接使用run_tests.py
|
||||
python run_tests.py --all --no-report
|
||||
```
|
||||
|
||||
## Allure报告路径
|
||||
|
||||
- **结果目录**: `zhyy/test_case/reports/allure-results`
|
||||
- **报告目录**: `zhyy/test_case/reports/allure-report`
|
||||
- **Jenkins中查看**: 构建完成后点击左侧 "Allure Report" 链接
|
||||
|
||||
## 环境变量
|
||||
|
||||
Jenkins会自动设置以下环境变量:
|
||||
- `WORKSPACE`: Jenkins工作空间路径
|
||||
- `BUILD_NUMBER`: 构建编号
|
||||
- `JENKINS_URL`: Jenkins服务器地址
|
||||
|
||||
`run_tests.py` 会自动检测Jenkins环境并调整路径。
|
||||
|
||||
## 详细文档
|
||||
|
||||
更多配置说明请参考:`JENKINS_SETUP.md`
|
||||
Reference in New Issue
Block a user