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

Kevin · April 28, 2019 · Last by heboqiang replied at August 23, 2019 · 1193 hits

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 ,使两边对上:

共收到 8 条回复 时间 点赞


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

Kevin #2 · April 28, 2019 作者
Jerry li 回复

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

Kevin 回复

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

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

dan 回复

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

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 用户的权限没有分配这个文件夹

这个是为啥

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up