【记录日常问题】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报告就显示数据啦~
请添加图片描述

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐