Maven命令行构建与Hudson构建

时间:2016-06-05 14:24:35

标签: maven hudson

我在命令行上运行命令mvn clean package cf:push,它完美无缺地运行。我也在同一台机器上安装了Hudson。我使用Hudson Maven插件使用相同的Maven环境并运行相同的目标clean package cf:push,但我收到以下错误:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.652 s
[INFO] Finished at: 2016-06-05T09:01:45+00:00
[INFO] Final Memory: 38M/357M
[INFO] ------------------------------------------------------------------------
[INFO] o.h.m.e.h.MavenExecutionResultHandler - Build failed with exception(s)
[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.cloudfoundry:cf-maven-plugin:1.1.2:push (default-cli) on project gs-messaging-redis: Execution default-cli of goal org.cloudfoundry:cf-maven-plugin:1.1.2:push failed: An API incompatibility was encountered while executing org.cloudfoundry:cf-maven-plugin:1.1.2:push: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V

1 个答案:

答案 0 :(得分:0)

我查看了日志,我发现下面有些棘手的事情: 如果我像这样clean package cf:push -e设定哈德森的目标,实际上是由哈德森执行的这样的推荐:

mvn clean package cf:push -e -V -B -Dmaven.ext.class.path=/home/dingjianrui/hudson/maven/slavebundle/resources:/home/dingjianrui/hudson/maven/slavebundle/lib/maven3-eventspy-3.1.jar:/opt/tomcat/apache-tomcat-8.0.33/webapps/hudson/WEB-INF/lib/hudson-remoting-3.0.3.jar -Dhudson.eventspy.port=38570 -f pom.xml

这个命令实际上注入了一些Hudson本身特别使用的其他库,我猜它们用于远程控制并将日志输出到某个地方,我无法禁用它们。

注入的库实际上与maven库存在冲突。这就是我收到以下警告的原因:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/dingjianrui/hudson/maven/slavebundle/lib/maven3-eventspy-runtime.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/maven/lib/slf4j-simple.jar!/org/slf4j/impl/StaticLoggerBinder.class]

它也与我的插件库发生冲突,最终导致整个事情失败。

[INFO] o.h.m.e.h.MavenExecutionResultHandler - [1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.cloudfoundry:cf-maven-plugin:1.1.2:push (default-cli) on project gs-messaging-redis: Execution default-cli of goal org.cloudfoundry:cf-maven-plugin:1.1.2:push failed: An API incompatibility was encountered while executing org.cloudfoundry:cf-maven-plugin:1.1.2:push: java.lang.NoSuchMethodError: 

请记住,如果我在命令行上运行相同的命令mvn clean package cf:push -e,一切正常。 我的问题是如何避免注入的Hudson库与我的插件库之间的冲突?什么是上面的根本原因?

感谢。