当前位置: 首页 > 知识库问答 >
问题:

Maven 3 Jenkins插件——Hello World示例的“构建失败”

邹涵畅
2023-03-14

我是第一次使用Jenkins/Maven,并遵循这两个教程编写Jenkins插件:https://wiki.jenkins-ci.org/display/JENKINS/Plugin教程和http://cleantestcode.wordpress.com/2013/11/03/how-to-write-a-jenkins-plugin-part-1/.

到目前为止,我在Windows上的提示下输入了以下命令/数据:

  1. mvn hpi:创建-Pjenkins

步骤5的结果是“BUILD FAILURE”,输出如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.9:test           (default-test) on project hello_world: There are test failures. [ERROR] 
[ERROR] Please refer to C:\$HOME\hello_world\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR]  
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.

我尝试了“mvn install-DskipTests”,但这样(我不知道该如何表达)命令提示符就再也不会出现,我无法输入更多的命令。

我的问题如下:

  1. 我没有修改“mvn hpi:create-Pjenkins”生成的任何文件,那么是什么导致默认测试失败呢
  2. 如果没有“-Pjenkins”标志,“mvn hpi:create”命令也会导致构建失败。添加“-Pjenkins”标志的效果如何

提前感谢任何答案。

[编辑]以下是Surefire报告的内容:

    -------------------------------------------------------------------------------
Test set: InjectedTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 14.697 sec <<< FAILURE!
org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyTestSuite(org.jvnet.hudson.test.junit.FailedTest)  Time elapsed: 0.012 sec  <<< ERROR!
java.lang.ArrayIndexOutOfBoundsException: -1
    at com.thoughtworks.xstream.core.util.OrderRetainingMap.entrySet(OrderRetainingMap.java:77)
    at java.util.HashMap.putMapEntries(HashMap.java:511)
    at java.util.HashMap.putAll(HashMap.java:784)
    at com.thoughtworks.xstream.core.util.OrderRetainingMap.<init>(OrderRetainingMap.java:36)
    at com.thoughtworks.xstream.converters.reflection.FieldDictionary.buildMap(FieldDictionary.java:135)
    at com.thoughtworks.xstream.converters.reflection.FieldDictionary.fieldsFor(FieldDictionary.java:76)
    at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:127)
    at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:149)
    at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:108)
    at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
    at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
    at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
    at com.thoughtworks.xstream.XStream.marshal(XStream.java:898)
    at com.thoughtworks.xstream.XStream.marshal(XStream.java:887)
    at com.thoughtworks.xstream.XStream.toXML(XStream.java:860)
    at hudson.XmlFile.write(XmlFile.java:179)
    at jenkins.model.Jenkins.save(Jenkins.java:2656)
    at jenkins.model.Jenkins.setNoUsageStatistics(Jenkins.java:988)
    at org.jvnet.hudson.test.HudsonTestCase.setUp(HudsonTestCase.java:320)
    at org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyTestSuite.setUp(JellyTestSuiteBuilder.java:133)
    at org.jvnet.hudson.test.junit.GroupedTest.run(GroupedTest.java:49)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
testCliSanity(org.jvnet.hudson.test.PluginAutomaticTestBuilder$CliSanityTest)  Time elapsed: 0.027 sec  <<< ERROR!
java.lang.IllegalStateException: second instance
    at jenkins.model.Jenkins.<init>(Jenkins.java:758)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at org.jvnet.hudson.test.HudsonTestCase.newHudson(HudsonTestCase.java:469)
    at org.jvnet.hudson.test.HudsonTestCase.setUp(HudsonTestCase.java:312)
    at junit.framework.TestCase.runBare(TestCase.java:139)
    at org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:290)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)

共有1个答案

司寇祺
2023-03-14

尝试跳过测试,将第5个命令更改为:5。mvn安装-DskipTests

 类似资料:
  • 这个示例用于运行测试XQuery程序执行环境是否正常工作。 执行上面示例代码,得到以下结果 - 该程序创建一个名为的临时变量,并为其分配一个字符串值。 输出是一个XML元素,包含一个包含变量值的消息元素。 也可以使用序列化选项来定义序列化和输出媒体类型,从而使XQuery返回纯文本。 例如,要将消息作为文本输出,请将序列化指定为文本,将指定为。

  • 我用的是Android studio。显示此错误的所有新项目: 生成文件'/Users/messan/AndroidStudioProjects/MyApplication/Build。格拉德尔线:3 在以下任何来源中均未找到插件[id:'com.android.application',版本:'7.1.1',apply:false]: > 例外是:org。格雷德尔。应用程序编程接口。插件。Unk

  • 示例插件 events-http-specific.py-HTTP特定的事件。 http-stream-modify.py-修改流式响应。 commands-flows.py —将流作为命令参数处理。 log-events.py —将消息发布到mitmproxy的事件日志。 scripting-minimal-example.py wsgi-flask-app.py —在mitmproxy中托管W

  • 我第一次安装PhoneGap并试图构建“HelloWorld”项目,但每次都失败了。即使我只创建了一个新项目,也可以在尝试构建之后直接添加Android作为平台。 我使用以下命令:-cordova创建你好com.example.helloHelloWorld-cd Hello/-cordova平台添加android-phonegap本地构建android 错误:http://pastebin.co

  • 我刚通过自制安装了Gradle。版本7.0。我运行了一个hello world任务,没有出错。然后,我按照说明安装ml-gradle(https://github.com/marklogic-community/ml-gradle)。我得到构建失败的原因是: 错误:在任务“:MLNewProject”(键入“NewProjectTask”)的配置中发现了一些问题。 > 类型'NewProjectT

  • 比较简单的 Android Gradle 项目的 build.gradle 如下: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.1' } } apply plugin: 'co