在Jenkins中使用插件生成Allure报告时无法计算绝对UR

在Jenkins中使用插件生成Allure报告时无法计算绝对UR

本文介绍了在Jenkins中使用插件生成Allure报告时无法计算绝对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

测试执行后无法在Jenkins中生成魅力报告.在控制台输出中得到这样的错误:

Cannot generate Allure report in Jenkins after test execution.Get such error in console output:

    > ERROR: Build step failed with exception
    > java.lang.IllegalStateException: Root URL isn't configured yet. Cannot
    > compute absolute URL. at
    > hudson.model.AbstractItem.getAbsoluteUrl(AbstractItem.java:483) at
    > ru.yandex.qatools.allure.jenkins.AllureReportPublisher.generateReport(AllureReportPublisher.java:169)
    > at
    > ru.yandex.qatools.allure.jenkins.AllureReportPublisher.perform(AllureReportPublisher.java:93)
    > at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    > at
    > hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    > at
    > hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
    > at
    > hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1047)
    > at
    > hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
    > at hudson.model.Run.execute(Run.java:1745) at
    > hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) at
    > hudson.model.ResourceController.execute(ResourceController.java:98) at
    > hudson.model.Executor.run(Executor.java:410) Build step 'Allure
    > Report' marked build as failure Finished: FAILURE

在我的项目中,我使用TestNG,这是pom.xml文件的示例:

In my project I use TestNG, here is and example of my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<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.paycasso</groupId>
    <artifactId>test-app</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <allure.version>1.4.11</allure.version>
        <aspectj.version>1.8.5</aspectj.version>
        <suite>smokeSuite</suite>
        <user>stg01</user>
        <pwd>verify10</pwd>
        <env>staging01</env>
    </properties>

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

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>2.53.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>3.4.1</version>
        </dependency>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${suite}.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <parallel>methods</parallel>
                    <threadCount>10</threadCount>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>
                        -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                    </argLine>
                    <systemPropertyVariables>
                        <user>${user}</user>
                        <password>${pwd}</password>
                        <environment>https://${env}-api.paycasso.com</environment>
                    </systemPropertyVariables>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <excludeDefaults>true</excludeDefaults>
        <plugins>
            <plugin>
                <groupId>ru.yandex.qatools.allure</groupId>
                <artifactId>allure-maven-plugin</artifactId>
                <version>2.0</version>
            </plugin>
        </plugins>
    </reporting>

</project>

当我尝试使用mvn test命令从控制台生成报告时,一切正常.

When i'm trying to generate report from console using mvn test command everything works good.

请帮助澄清我错了.

推荐答案

与Anna Kaygorodova相同,但是:Get YourHostName:echo $ HOSTNAME(在Linux和Mac中)将Configure System-> Jenkins Location-> Jenkins URL设置为 http://YourHostName:8080 通过 http://您的服务器IP:8080

Same as Anna Kaygorodova but: Get YourHostName: echo $HOSTNAME (in linux, mac) Set Configure System -> Jenkins Location -> Jenkins URL to http://YourHostName:8080 Open Jenkins via http://YourServerIP:8080

这篇关于在Jenkins中使用插件生成Allure报告时无法计算绝对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 13:08