第一步:在docker下部署jenkins
第二步:在docker中搭建python环境
第三步:进入docker容器在jenkins工作目录下安装allure安装包并配置环境变量
vi /etc/profile
在打开的文件中添加
export ALLURE_HOME=/var/jenkins_home/workspace/allure-2.13.2
export PATH=$PATH:$ALLURE_HOME:/bin
第四步:浏览器打开jenkins
新建工程如(interface-automation)后在首页系统管理》插件管理下安装以下插件
Allure Jenkins Plugin(allure报告)
git(为了使用GitHub)
Localization: Chinese (Simplified)(汉化)
第五步:配置allure commandline
在首页》系统配置》全局工具配置》allure commandline下
不要选择自动安装
别名:allure(自己定义)
安装目录:/var/jenkins_home/workspace/allure-2.13.2(docker容器里安装的allure路径,配置时不需要到bin目录)
第六步:在interface-automation中配置相关参数
1.点击“配置”:源码管理中选择“Git”
Repositories中Repository URL:https://github.com/***(URL为GitHub中相应库地址)
Credentials:此为GitHub的账号密码
2.构建触发器中
python3 -m pytest --alluredir=/var/jenkins_home/workspace/interface-automation/allure-results /var/jenkins_home/workspace/interface-automation/modo_api_pytest/Apisite/test_case/test_1_account_select.py
(指定python版本,指定allure报告生成地址)
3.构建后的操作
选择Allure Report
Path:allure-results(与上面报告路径保持一致)