问答 各位测试老师,能否指导一下 jenkins 集成 allure 报告的配置

ljn · 2025年02月13日 · 最后由 ljn 回复于 2025年02月14日 · 3984 次阅读

执行脚本:

运行测试并生成 Allure 结果数据

cd /var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases
pytest --alluredir=allure-results
echo "Current directory: $(pwd)"
echo "Contents of current directory:"
ls -l

构建后操作:


构建过程中输出显示找不到 allure_results
++ pwd

  • echo 'Current directory: /var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases' Current directory: /var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases
  • echo 'Contents of current directory:' Contents of current directory:
  • ls -l total 2380 -rw-r--r-- 1 root root 0 Feb 13 09:07 init.py drwxr-xr-x 1 root root 4096 Feb 13 09:08 pycache drwxr-xr-x 1 root root 4096 Feb 13 09:07 allure-report drwxr-xr-x 1 root root 4096 Feb 13 09:08 allure-results -rw-r--r-- 1 root root 776554 Feb 13 09:00 app.js drwxr-xr-x 1 root root 4096 Feb 13 09:00 data drwxr-xr-x 1 root root 4096 Feb 13 09:00 export -rw-r--r-- 1 root root 15086 Feb 13 09:00 favicon.ico drwxr-xr-x 1 root root 4096 Feb 13 09:00 history drwxr-xr-x 1 root root 4096 Feb 13 09:07 html -rw-r--r-- 1 root root 665 Feb 13 09:00 index.html drwxr-xr-x 1 root root 4096 Feb 13 09:00 plugins -rw-r--r-- 1 root root 85783 Feb 13 09:08 report.html -rw-r--r-- 1 root root 1542785 Feb 13 09:00 styles.css -rw-r--r-- 1 root root 4789 Feb 13 09:07 test_group_kaipiao.py drwxr-xr-x 1 root root 4096 Feb 13 09:00 widgets Script returned: [auto_test_invoice] $ /opt/allure/bin/allure generate -c -o /var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases/allure-report allure-results does not exist
共收到 6 条回复 时间 点赞
ljn #1 · 2025年02月13日 Author


不过我这个是在 WIndows 环境下的 Jenkins 构建配置

pytest --alluredir=/var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases/allure-results 改这个试试

ljn #4 · 2025年02月13日 Author
鲨鱼辣椒 回复

下面有配置 allure 的两个路径吗,我是拿 docker 启的 jenkins


这个地址应该指向 /var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases

ljn #6 · 2025年02月14日 Author

感谢各位老师回复,问题已解决

1:执行命令修改为 pytest --alluredir=/var/jenkins_home/workspace/auto_test_invoice/automation_test/invoice_auto_test/test_cases/allure-results

2:allure 结果和报告路径分别修改为 automation_test/invoice_auto_test/test_cases/allure-results 和 automation_test/invoice_auto_test/test_cases/allure-report

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册