持续集成 Jenkins+Allure+Pytest 环境,不会显示 Allure 报告是什么问题?

Kevin · 2019年04月28日 · 最后由 lyang1234 回复于 2020年06月10日 · 4772 次阅读

Pytest 环境:

platform linux -- Python 3.6.8, pytest-3.3.2, py-1.5.2, pluggy-0.9.0
rootdir: /home/user/pytest, inifile:
plugins: metadata-1.8.0, html-1.20.0, allure-adaptor-1.7.10

Jenkins 环境:

Jenkins ver. 2.164.2
Allure Jenkins plugin: 2.28.1

项目配置:

构建:
执行 shell:
python3 -m pytest -q test_sample.py --alluredir ${WORKSPACE}/allure-results
构建后操作:
Allure Report:
Results path: ${WORKSPACE}/allure-results
其它配置保持默认。

问题:

  1. 在项目中点击 Allure Report,提示:HTTP ERROR 404

  2. 执行构建后失败:

    [pytest] $ /bin/sh -xe /tmp/jenkins5150009942176255687.sh
    + python3 -m pytest -q test_sample.py --alluredir /home/user/pytest/allure-results
    ...                                                                      [100%]
    3 passed in 0.07 seconds
    [pytest] $ /var/lib/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure/bin/allure generate -c -o /home/user/pytest/allure-report
    Could not generate report: {}
    ......
    ERROR: Build step failed with exception
    ru.yandex.qatools.allure.jenkins.exception.AllurePluginException: Can not generate Allure Report, exit code: 1
    at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.generateReport(AllureReportPublisher.java:314)
    ......
    Build step 'Allure Report' marked build as failure
    由于构建失败而跳过归档
    Finished: FAILURE
    
最佳回复


你这两个地址对不上,所以 allure 找不到你的报告文件
你可以改下你的脚本,或者改下 Jenkins 里 allure report 的 results path ,使两边对上:

共收到 12 条回复 时间 点赞


你这两个地址对不上,所以 allure 找不到你的报告文件
你可以改下你的脚本,或者改下 Jenkins 里 allure report 的 results path ,使两边对上:

Kevin #11 · 2019年04月28日 Author
Jerry li 回复

是的,我也发现了,刚修改一致后,可以显示了,网上的教程还是很多坑啊😂
但是又出现了一个新问题,就是 Allure 报告中是空的😭

Kevin 回复

确认一下对应的目录是不是有生成对应的报告文件吧,脚本生成的数据文件 和 allure 生成的报告

Allure 本质上是个 report 转换工具,你的问题都是没有把转换后的报告生成到指定目录

秋草 回复

请问下如何转化后的报告生成到指定目录?我那边的确生成报告文件夹

Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /Users/liubc/PycharmProjects/demo0708/report
[report] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/jenkins3886212447333682060.sh

  • /Library/Frameworks/Python.framework/Versions/3.7/bin/pytest /Users/liubc/PycharmProjects/demo0708/testcases/test_03.py --alluredir /Users/liubc/PycharmProjects/demo0708/report/xml ============================= test session starts ============================== platform darwin -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0 rootdir: /Users/liubc/PycharmProjects/demo0708 plugins: sugar-0.9.2, assume-1.2.2, allure-pytest-2.6.2, ordering-0.6, rerunfailures-7.0 collected 1 item

../testcases/test_03.py .

INTERNALERROR> with open(destination, 'wb') as attached_file:
INTERNALERROR> PermissionError: [Errno 13] Permission denied: '/Users/liubc/PycharmProjects/demo0708/report/xml/2d973209-3ffd-4bf1-b717-e0ee38c87412-attachment.txt'

===================== 1 passed, 2 warnings in 0.03 seconds =====================
Build step 'Execute shell' marked build as failure
ERROR: Step ‘Allure Report’ aborted due to exception:
java.nio.file.AccessDeniedException: /Users/liubc/PycharmProjects/demo0708/report/xml/testrun.json
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
at java.nio.file.Files.newOutputStream(Files.java:216)
at java.nio.file.Files.newBufferedWriter(Files.java:2860)
at ru.yandex.qatools.allure.jenkins.callables.AbstractAddInfo.invoke(AbstractAddInfo.java:26)
at ru.yandex.qatools.allure.jenkins.callables.AbstractAddInfo.invoke(AbstractAddInfo.java:19)
at hudson.FilePath.act(FilePath.java:1076)
at hudson.FilePath.act(FilePath.java:1059)
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.addTestRunInfo(AllureReportPublisher.java:399)
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.prepareResults(AllureReportPublisher.java:390)
at ru.yandex.qatools.allure.jenkins.AllureReportPublisher.perform(AllureReportPublisher.java:230)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:79)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1843)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

想问下大家有遇到过这个问题吗?

刘博琛 回复

报权限不足了,看下是否 system 用户的权限没有分配这个文件夹

这个是为啥

提示报这个错误的来了 java.io.IOException: Can't find allure commandline 一时没有找到问题。


一个问题解决,另一个问题又来了。在 linux 下的 jenkins,但是 slave 在 windows 上,没有显示出报告。

12-27:这个问题解决了,就是相关的目录没有设置对,太依赖网上的文章描述了。只有掌握了原理才不至于陷入无助中。

moonlight 回复

你好,我也遇到您这边的这个问题,jenkins(linux)+ 执行机(windows);能说下是咋解决的吗?有几个问题想确认下:
1、jenkins 里设置的 allure path 直接写相对地址可以吗?还是得写 windows 环境下的绝对地址
2、脚本里面需要执行 "allure generate --clean reports/data -o reports/report" 这一步吗?还是只需要执行保存成 xml 的数据源就可以?
先谢过了


不好意思打扰了,刚自己乱试成功了

NASA 回复

有碰到同样的情况,请问是怎么解决的呀

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