错误1:有个pom文件内容错了,但是在jenkins上面编译的时候,控制台将这个错误信息给打出来了,maven的编译也打印了failed with error,但是jenkins的job并没有因此而停止,而是继续指后面的sonar分析去了,设置了sonar 的Skip analysis on build failure,以及设置post step的Run only if build succeeds,也都无果
[ERROR] BUILD ERROR [INFO] Failed to configure plugin parameters for: org.apache.maven.plugins:maven-dependency-plugin:2.0 Cause: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Dependency'
后来排查下来,怀疑是maven的缺陷导致的jenkins没有收到错误码来中断执行导致,遂升级maven到3.0.5,然后执行build,job中断了执行,目的达到,抛出的错误如下,该步的问题,基本解决
cause : Unable to parse configuration of mojo org.apache.maven.plugins:maven-dependency-plugin:2.1:copy: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Dependency' Stack trace : org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:copy (copy-libs) on project cifin-assembly-ace: Unable to parse configuration of mojo org.apache.maven.plugins:maven-dependency-plugin:2.1:copy: Error loading class 'org.apache.maven.plugin.dependency.fromConfiguration.Dependency' at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:221) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
问题2:jenkins执行job的build时,使用的是maven3.0.5,sonar配置时,sonar-maven-plugin配置的是1.0-beta2,导致报错:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:1.0-beta-2:sonar (default-cli) on project cifin-parent: Can not execute Sonar: UnsupportedOperationException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:1.0-beta-2:sonar (default-cli) on project cifin-parent: Can not execute Sonar at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
这个错误是由于sonar-maven-plugin导致的,可以参考以下文档
http://sonar.15.x6.nabble.com/sonar-maven-plugin-causes-UnsupportedOperationException-td5002455.html
修改jenkins config中的soanr配置中的sonar-maven-plugin version: 设置成2.0 (应该是2.0以后才支持maven 3.0.5)
问题3:升级了sonar-maven-plugin的versio到2.0, 或者不指定(不指定时,默认是最高version应该是),之前用maven 2.2.1编译的job,又出新状况了
[ERROR] FATAL ERROR [INFO] ------------------------------------------------------------------------ [INFO] PicoLifecycleException: method 'public void org.sonar.jpa.session.AbstractDatabaseConnector.start()', instance 'org.sonar.jpa.session.DriverDatabaseConnector@1304e60, java.lang.RuntimeException: wrapper Database schema must be updated [version/required=241/191]. Please browse to your sonar homepage. [INFO] ------------------------------------------------------------------------ [INFO] Trace
这又是个蛋疼的问题,解决办法只好是把sonar的配置再复制一份出来,maven2.2.1编译的,暂时用soanr-maven-plugin version=1.0的sonar来执行sonar分析,maven3.0.5的来用sonar-maven-plugin version=2.0来执行sonar分析
为什么不能一下升级到maven3.0.5,因为有些蛋疼的系统的pom写的不规范,maven3对pom的校验又比maven2严格,有些maven2下面编译没啥问题的系统,用maven3就编译不过了,除非推动他们去修改到那些不规范的pom