【问题标题】:allure-results does not exists in Jenkinsallure-results 在 Jenkins 中不存在
【发布时间】:2023-03-28 05:44:01
【问题描述】:

Allure 结果已生成 (xmls),可以通过在 allure-results 目录之外运行 allure serve 来查看,但是当在 Jenkins 中使用带有来自 Jenkins 工作区的相对路径的 allure 结果目录进行配置时,allure结果没有找到。估计路径有问题

[allure_test] $ /Users/me/.jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_2.7.0/bin/allure generate -c -o /Users/me/.jenkins /workspace/allure_test/allure-report 诱惑结果不存在 报告成功生成到 /Users/me/.jenkins/workspace/allure_test/allure-report 诱惑报告已成功生成。

为魅力报告定义的相对路径是
../../repos/partner-portal/target/allure-results

报告已生成,但没有结果

【问题讨论】:

    标签: jenkins report allure


    【解决方案1】:

    解决方法如下:
    1. 在您的工作空间内(对我来说是 D:\m\Automation Project\Tests),创建一个名为“target”的文件夹,其中包含两个子文件夹“allure-results”和“allure-reports”。

    1. 在 Jenkins 项目的 Post Build Actions 中提供这些条目。

    结果: target/allure-results
    报告路径: target/allure-reports

    现在运行您的测试,将生成魅力报告,没有任何问题。

    【讨论】:

      【解决方案2】:

      因为这个问题,我挣扎了超过 24 小时,整晚都无法入睡。没有与此相关的明确说明以及它是如何工作的。最后,我想通了。

      这个答案可能为时已晚,但您能否在您的工作区中创建“allure-results”文件夹(例如 /Users/me/.jenkins/workspace/allure_test/allure-results)?

      在 jenkins 中配置 Allure 报告并使用行为命令后,我终于看到了以下输出,并在我的 jenkins 构建计划中看到了工作报告:

      .
      .
      .
      .
      D:\PythonProject\PythonBehave>behave -f allure_behave.formatter:AllureFormatter -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-results D:\PythonProject\PythonBehave\features 
      
      Failing scenarios:
        features/example.feature:17  user can search text in google -- @2.2 Incorrect
        features/github_login.feature:13  User attempt to login with wrong username and password -- @1.1 InCorrect
        features/github_login.feature:14  User attempt to login with wrong username and password -- @1.2 InCorrect
        features/github_login.feature:18  User attempt to login with correct username and password
      
      0 features passed, 2 failed, 0 skipped
      3 scenarios passed, 4 failed, 0 skipped
      12 steps passed, 4 failed, 8 skipped, 0 undefined
      Took 3m24.651s
      
      D:\PythonProject\PythonBehave>exit 1 
      Build step 'Custom Python Builder' marked build as failure
      [PythonAllure] $ C:\Users\Alex\.jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\Allure_2.13.1\bin\allure.bat generate C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-results -c -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
      Report successfully generated to C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
      Allure report was successfully generated.
      Creating artifact for the build.
      Artifact was added to the build.
      Finished: FAILURE
      

      当我的工作区中没有 allure-results 文件夹时,我曾经得到这个输出:

      [PythonAllure] $ C:\Users\Alex\.jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\Allure_2.13.1\bin\allure.bat generate -c -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
      

      【讨论】:

        【解决方案3】:

        我们没有在 UI 上使用任何后期构建步骤,而是使用 jenkins 管道 groovy 脚本,如下所示:

        def allureReportsGenerationTask() {
        try {
        allure([includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'target/allure-results']]])
        } catch(Exception error) {
        println("Caught Exception: ${error}")
        }
        }
        

        项目结构只是这样

         ProjectRepo
               - src
               - target
                 -alure-results 
               - pom.xml 
               - testng.xml
        

        在这种情况下,我们正在生成 allure-results,但它没有在 Jenkins 管道 allure 插件中被选中。 ON UI 下面的命令一直在运行

        /opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
        

        您可以看到 Jenkins 在上述 Jenkins 管道命令中无法找到用于生成参数的 allure-results

        我们在 pom.xml maven-surefire-plugin 中添加了以下参数

           <systemPropertyVariables>
            <allure.results.directory>../target/allure-results</allure.results.directory>
             </systemPropertyVariables>
        

        现在项目结构变成了

        -ProjectRepo - 源代码 - pom.xml - testng.xml

        • 目标 -allure-results

        现在通过管道脚本运行相同的,我们能够运行以下命令

        /opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate /opt/jenkins/workspace/ProjectRepoPipeline/target/allure-results -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
        

        ProjectRepoPipeline - 这是运行 CI/CD 的 Jenkins 管道名称

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-11-19
          • 2022-10-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-03
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多