为什么 Hudson 的 Maven 测试构建失败

发布于 2024-12-05 09:01:17 字数 7167 浏览 1 评论 0原文

我的项目中有一个 TestNG 测试。 当我使用 mvn integration-test 从命令行运行它时,它显示:

运行测试套件 测试... 测试运行:1,失败:0,错误:0,跳过:0,已用时间:0.29 秒

结果:

测试运行:1,失败:0,错误:0,跳过:0

[信息]

[信息]取得成功[信息]

[INFO] 总时间:1.468 秒 [INFO] 完成时间:东部夏令时间 9 月 20 日星期二 11:55:23

2011 [信息]最终内存:5M/247M [信息]

在我在 Hudson 中创建类型为 构建 Maven 2/3 项目(旧版) 的构建之后。 在目标中我说集成测试。 最后,我立即构建,然后我在 Hudson 控制台输出中看到的是:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building working 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default) @ working ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.9:test (default) @ working ---
[INFO] Surefire report directory: C:\Users\ybr\workspace\working\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Testing  ...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.29 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[HUDSON] Recording test results
projectSucceeded m.no:working:0.0.1-SNAPSHOT
projectFailed m.no:working:0.0.1-SNAPSHOT
sessionEnded
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.253s
[INFO] Finished at: Tue Sep 20 11:56:27 EEST 2011
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
mavenExecutionResult exceptions not empty
org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
    at org.apache.maven.lifecycle.internal.BuilderCommon.handleBuildError(BuilderCommon.java:128)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:95)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:146)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:124)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
    at hudson.remoting.UserRequest.perform(UserRequest.java:114)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:283)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
    at hudson.model.RunMap$2.compare(RunMap.java:188)

是否有人解决了这个问题,并且可以写出它是如何解决的。 先感谢您。

我的POM是这样的:

<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>comcom.no</groupId>
<artifactId>working</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>working</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<build>

    <testSourceDirectory>src\test\java\m.no.working</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src\test\java\testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>


<dependencies>



    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.5.0</version>
    </dependency>

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

</dependencies>

I have one TestNG test in my project.
When I run it from command line with mvn integration-test it says:

Running TestSuite
Testing ...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.29 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]

[INFO] BUILD SUCCESS [INFO]

[INFO] Total time: 1.468s [INFO] Finished at: Tue Sep 20 11:55:23 EEST

2011 [INFO] Final Memory: 5M/247M [INFO]

After I create a build in Hudson of type Build a Maven 2/3 project (Legacy).
In goals I say integration-test.
In the end I do Build now and then what I see in Hudson console output is:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building working 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default) @ working ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.9:test (default) @ working ---
[INFO] Surefire report directory: C:\Users\ybr\workspace\working\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Testing  ...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.29 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[HUDSON] Recording test results
projectSucceeded m.no:working:0.0.1-SNAPSHOT
projectFailed m.no:working:0.0.1-SNAPSHOT
sessionEnded
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.253s
[INFO] Finished at: Tue Sep 20 11:56:27 EEST 2011
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
mavenExecutionResult exceptions not empty
org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
    at org.apache.maven.lifecycle.internal.BuilderCommon.handleBuildError(BuilderCommon.java:128)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:95)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:146)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:124)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
    at hudson.remoting.UserRequest.perform(UserRequest.java:114)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:283)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
    at hudson.model.RunMap$2.compare(RunMap.java:188)

Did anybody counter the problem and could write how it was solved.
Thank you in advance.

My POM is like that:

<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>comcom.no</groupId>
<artifactId>working</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>working</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<build>

    <testSourceDirectory>src\test\java\m.no.working</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src\test\java\testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>


<dependencies>



    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.5.0</version>
    </dependency>

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

</dependencies>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶视觉 2024-12-12 09:01:17

您使用多线程吗?
Jenkins 上有一个已修复的问题导致多线程失败:

https://issues .jenkins-ci.org/browse/JENKINS-9183

另外,您使用的是 Jenkins 还是 Hudson?
您考虑过迁移到詹金斯吗?

请参考:

https://wiki.jenkins-ci .org/display/JENKINS/Upgrading+from+Hudson+to+Jenkins

这将解决 Jenkins 上已修复的许多问题。
也许你可以尝试为此做一个 POC,然后建议将 Hudson 转移到 Jenkins 中。

Are you using multiple threads?
There is a Fixed issue on Jenkins that was causing this failure regarding multi threads:

https://issues.jenkins-ci.org/browse/JENKINS-9183

Also, are you using Jenkins or Hudson?
Have you consider migrating to Jenkins?

Please refer to:

https://wiki.jenkins-ci.org/display/JENKINS/Upgrading+from+Hudson+to+Jenkins

That will solve many issues that are fixed on Jenkins.
Maybe you can try doing a POC for this and then propose moving Hudson into Jenkins.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文