如何在项目用例执行完成后,生成如图的效果呢?
下面是详细的配置过程,特别注意的是路径,其它都很简单。
【前置条件】:allure环境配置
1.path加入allure路径到bin。如:D:\allure-commandline-2.15.0\allure-2.15.0\bin
2.Jenkins系统变量配置;config System.添加Allure Report路径
key:Allure
Value:D:\allure-commandline-2.15.0\allure-2.15.0
如图:
3.Jenkins添加全局变量配置Global Tool Configuration
*************************************************************************************************************************************************
Jenkins配置
1.新建一个自由风格的项目,Gerneral下勾选 【GitHub项目】,并输入URL。如:https://gitee.com/wang-jianhua1/pyauto.git/
2.源码管理
2.1 选择Git,并输入 Repository URL,如:https://gitee.com/wang-jianhua1/pyauto.git/
Credentials 输入正确的gitee账号和密码
2.2 Branches to build 指定分支为 */master. 如下图:
3.构建环境
勾选--> Delete workspace before build starts (每次构建前删除历史目录下的项目文件)
勾选--> Add timestamps to the console output (可选项,在构建过程显示时间)
4.构建(核心)
本地是执行Windows 批处理命令。Execute windows batch command
命令:
cd myPytest cd到项目路径
python run_pytest.py
python -m pytest -v -s --alluredir .\Outputs\allure_report
copy environment.properties .\Outputs\allure_report\environment.properties
项目路径说明:
5.构建后操作
选择:Allure Report
Path输入报告生成的路径,如下:myPytest\Outputs\allure_report (注意这里一定要加上项目文件名)
6.Done 报告已生成成功
特别注意报告生成的路径不是和项目一起的,路径一定是在项目路径外侧,用例执行的日志文件output文件是在项目里的,这点要特别注意。