Jenkins无法为生成的倾向性报告xml文件识别正确的目录

时间:2016-05-04 06:40:19

标签: jenkins allure

我已成功将Allure报告集成到基于maven的testNG项目,并能够使用jetty服务器查看该报告。 但是现在我正按照这里建议的说明,尝试将诱惑报告与詹金斯整合在一起 - http://wiki.qatools.ru/display/AL/Allure+Jenkins+Plugin 我现在能够在我的jenkins页面上看到诱惑图标,但如果我点击此图标,我会看到404 - '页面未找到'错误。

我进一步调试控制台输出并看到发生异常 -

Exception in thread "main" ru.yandex.qatools.allure.data.ReportGenerationException: Could not find any allure results
at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureReportGenerator.java:58)
at ru.yandex.qatools.allure.data.AllureReportGenerator.generate(AllureReportGenerator.java:53)
at ru.yandex.qatools.allure.AllureMain.main(AllureMain.java:48)
Command aborted due to exception {}.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:153)
at ru.yandex.qatools.allure.command.ReportGenerate.runUnsafe(ReportGenerate.java:48)
at ru.yandex.qatools.allure.command.AbstractCommand.run(AbstractCommand.java:52)
at ru.yandex.qatools.allure.CommandLine.main(CommandLine.java:46)

我想这个错误即将到来,因为jenkins无法识别出诱惑报告xml的正确目录,并且要纠正我们必须修改pom.xml以便它能告诉jenkins正确目录的路径是什么。

有人请建议我在这里缺少什么。

2 个答案:

答案 0 :(得分:3)

您需要将您的Maven项目中的Allure结果路径从project.name\target\allure-results提取到Jenkins,并将其添加到Jenkins \ Your Job \ Configure \ Allure Report \ Result中。

之后,您需要以两种方式之一更改Jenkins安全设置。

从詹金斯开始:

java 
-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';" 
-Djenkins.model.DirectoryBrowserSupport.CSP="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"
-jar jenkins.war

http://Jenkins/script

中运行这两个脚本
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';")

System.setProperty("jenkins.model.DirectoryBrowserSupport.CSP", "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';")

编辑: 我刚刚找到了第三种方法。在你的Jenkins文件夹中打开jenkins.XML并添加

-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';" -Djenkins.model.DirectoryBrowserSupport.CSP="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';" 

参数。

编辑:

你要求的pom.XML:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.siba</groupId>
  <artifactId>com.siba.selenium</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>selenium tests</name>
  <description>selenium tests</description>

  <!-- Change from here -->

<repositories>
    <repository>
        <id>central</id>
        <name>bintray</name>
        <url>http://jcenter.bintray.com</url>
    </repository>
</repositories>

<packaging>jar</packaging>

<properties>
    <aspectj.version>1.7.4</aspectj.version>
    <allure.version>1.4.23</allure.version>
</properties>

<dependencies>

    <dependency>
        <groupId>ru.yandex.qatools.allure</groupId>
        <artifactId>allure-testng-adaptor</artifactId>
        <version>${allure.version}</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.0</version>
    </dependency>

    <dependency> 
        <groupId>com.microsoft.sqlserver</groupId> 
        <artifactId>sqljdbc4</artifactId> 
        <version>4.0</version>
        <scope>runtime</scope>
    </dependency> 

</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14</version>
            <configuration>
                <testFailureIgnore>false</testFailureIgnore>
                <argLine>
                    -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins> 
</build>
</project>

答案 1 :(得分:1)

最后我得到了答案。问题是我的jenkins配置不是在倾向报告中。我以不正确的方式导入我的项目,所以我的jenkins试图在jenkin的工作区目录中找到报告,但什么都没有。

所以我做了,我将我的maven项目重新导入jenkins作为一个自由风格的项目,并将自定义工作区设置为我的实际项目目录。现在一切正常。