【记录日常问题】jenkins中生成的allure报告空白/没有数据
问题:直接拉取的git代码在本地jenkins部署运行(shell命令运行项目的run.py文件),构建成功,但allure报告空白/无数据
框架:httprunner + pytest + jenkins + git + allure 
1、查看构建日志:jenkins的工作空间没有生成results文件 
2、尝试在本地打开jenkins的工作空间,运行run.py文件
- 如下图,pytest显示python路径有问题
- 原因:前段时间不小心卸载了python3.9的相关东西;
- 解决:需重新下载个python3.9,配置python环境、pytest的python路径

自己的 run.py文件,用来执行生成相关报告
jenkins配置Shell命令运行python3.9 run.py文件
def env_clear():
path = os.getcwd()
if os.path.exists(path + "/results"):
os.system("rm -rf results")
if os.path.exists(path + "/reports"):
os.system("rm -rf reports")
cmd = 'pytest testcases --alluredir results'
os.system(cmd)
cmd = 'allure generate results -o reports --clean'
os.system(cmd)
- MAC电脑相关配置
- bash环境配置:open ~/.bash_profile
- 配置完刷新:source ~/.bash_profile
- pytest配置:vi /usr/local/bin/pytest

3、再在jenkins工作空间运行在run.py文件
- 问题:无 allure-pytest依赖包

需要在终端安装:httprunner、allure-pytest、allure依赖包(项目框架需要这些,给一起安装)
pip3 install httprunner
pip3 install allure-pytest==2.9.45 -i https://mirrors.aliyun.com/pypi/simple
brew install allure
再运行后: 
4、最后再在jenkins构建下,allure报告就显示数据啦~ 
|