Jenkins not able to identify the correct directory for the generated allure report xml file

早过忘川 提交于 2019-12-02 01:58:41

You need to fetch your Allure results path from your Maven project to Jenkins from project.name\target\allure-results and add it in Jenkins\Your Job\Configure\Allure Report\Result.

After that you will need to change Jenkins security setting in one of 2 ways.

By starting Jenkins from:

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

By running this two scripts in 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';")

edit: I just found 3rd way to do this. In your Jenkins folder open jenkins.XML and add

-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';" 

to arguments.

Edit:

pom.XML you asked for:

<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>

Finally I got the answer. The problem was my jenkins configuration not in allure report. I was importing my project in a incorrect way so my jenkins was trying to find the report in jenkin's workspace directory but there was nothing.

So what I did, I re-import my maven project to jenkins as a free-style project and set the custom workspace to my actual project directory. Now everything works fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!