maven release plugin and multi-module releases with Sonar

1,047 views
Skip to first unread message

Jeff

unread,
Aug 6, 2013, 5:17:32 PM8/6/13
to jenkins...@googlegroups.com
I have a post-build action that runs Sonar analysis on our projects. 

I can't say that I know whether this worked before since we have very few multi-module projects but after the release:perform phase when doing a Maven release, it updates and checks in the POMs with the next DEV version and then immediately calls the Sonar action.   When Sonar attempts to run, it can't find some JAR's that are part of the multi-module project because it actually hasn't done a build yet for the new DEV version.

Am I doing something wrong or is this a problem with the release process or am I missing something simple?

--
Jeff Vincent
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

Jeff

unread,
Aug 6, 2013, 7:30:51 PM8/6/13
to jenkins...@googlegroups.com
If it helps...here is the Jenkins console output from the failed release.  I've removed much of the nitty gritty details until the end portion that fails.  Hopefully it makes sense.

In all steps, the reactor build order is: apps-thor --> thor-models --> thor-service-wrapper --> thor-web.  

However, in the step that fails, it shows the correct order, then appears to do: apps-thor --> thor-web and skips models and wrapper and shows them as "skipped".

During a normal build of the apps-thor parent pom, I don't see it attempt to resolve any POM or JAR from any of the modules, but in the end failure case it does.

Deleting project workspace... done
Checkout:
Parsing POMs
Executing Maven:  -B -f /home/adminuser/.jenkins-slave/workspace/apps-THOR/pom.xml -DdevelopmentVersion=1.6.6-SNAPSHOT -DreleaseVersion=1.6.5 -Dresume=false release:prepare release:perform -Darguments=-DskipTests
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] apps-thor
[INFO] thor-models
[INFO] thor-service-wrapper
[INFO] thor-web
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building apps-thor 1.6.5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-release-plugin:2.4.1:prepare (default-cli) @ apps-thor ---
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Build Order:
[INFO] [INFO] 
[INFO] [INFO] apps-thor
[INFO] [INFO] thor-models
[INFO] [INFO] thor-service-wrapper
[INFO] [INFO] thor-web
[INFO] [INFO]                                                                         
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building apps-thor 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building thor-models 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building thor-service-wrapper 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO] 
[INFO] [INFO] apps-thor ..................................... SUCCESS [1.772s]
[INFO] [INFO] thor-models ....................................... SUCCESS [7.621s]
[INFO] [INFO] thor-service-wrapper .............................. SUCCESS [2.794s]
[INFO] [INFO] thor-web .......................................... SUCCESS [1:57.294s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 2:10.135s
[INFO] [INFO] Finished at: Tue Aug 06 11:17:35 MDT 2013
[INFO] [INFO] Final Memory: 44M/265M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] --- maven-release-plugin:2.4.1:perform (default-cli) @ apps-thor ---
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Build Order:
[INFO] [INFO] 
[INFO] [INFO] apps-thor
[INFO] [INFO] thor-models
[INFO] [INFO] thor-service-wrapper
[INFO] [INFO] thor-web
[INFO] [INFO]                                                                         
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building apps-thor 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO]                                                                         
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building thor-models 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building thor-service-wrapper 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO]                                                                         
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building thor-web 1.6.5
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] 
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary:
[INFO] [INFO] 
[INFO] [INFO] apps-thor ..................................... SUCCESS [6.141s]
[INFO] [INFO] thor-models ....................................... SUCCESS [17.717s]
[INFO] [INFO] thor-service-wrapper .............................. SUCCESS [9.472s]
[INFO] [INFO] thor-web .......................................... SUCCESS [2:20.936s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 2:55.036s
[INFO] [INFO] Finished at: Tue Aug 06 11:21:00 MDT 2013
[INFO] [INFO] Final Memory: 50M/248M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Cleaning up after release...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] apps-thor ..................................... SUCCESS [5:43.537s]
[INFO] thor-models ....................................... SKIPPED
[INFO] thor-service-wrapper .............................. SKIPPED
[INFO] thor-web .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5:45.582s
[INFO] Finished at: Tue Aug 06 11:21:01 MDT 2013
[INFO] Final Memory: 12M/172M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /home/adminuser/.jenkins-slave/workspace/apps-THOR/thor-web/pom.xml to /home/tomcat7/.jenkins/jobs/apps-THOR/modules/com.mycompany.apps$thor-web/builds/2013-08-06_11-15-05/archive/com.mycompany.apps/thor-web/1.6.5-SNAPSHOT/thor-web-1.6.5-SNAPSHOT.pom
[JENKINS] Archiving /home/adminuser/.jenkins-slave/workspace/apps-THOR/pom.xml to /home/tomcat7/.jenkins/jobs/apps-THOR/modules/com.mycompany.apps$apps-thor/builds/2013-08-06_11-15-05/archive/com.mycompany.apps/apps-thor/1.6.5-SNAPSHOT/apps-thor-1.6.5-SNAPSHOT.pom
[JENKINS] Archiving /home/adminuser/.jenkins-slave/workspace/apps-THOR/thor-models/pom.xml to /home/tomcat7/.jenkins/jobs/apps-THOR/modules/com.mycompany.apps$thor-models/builds/2013-08-06_11-15-06/archive/com.mycompany.apps/thor-models/1.6.5-SNAPSHOT/thor-models-1.6.5-SNAPSHOT.pom
[JENKINS] Archiving /home/adminuser/.jenkins-slave/workspace/apps-THOR/thor-service-wrapper/pom.xml to /home/tomcat7/.jenkins/jobs/apps-THOR/modules/com.mycompany.apps$thor-service-wrapper/builds/2013-08-06_11-15-06/archive/com.mycompany.apps/thor-service-wrapper/1.6.5-SNAPSHOT/thor-service-wrapper-1.6.5-SNAPSHOT.pom
Waiting for Jenkins to finish collecting data
channel stopped

[apps-THOR] $ /home/adminuser/.jenkins-slave/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.0.4/bin/mvn -f /home/adminuser/.jenkins-slave/workspace/apps-THOR/pom.xml -DMVN_RELEASE_VERSION=1.6.5 -DMVN_DEV_VERSION=1.6.6-SNAPSHOT -DMVN_ISDRYRUN=false -e -B sonar:sonar "-Dsonar.profile=Sonar" -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://sonar-db.mycompany.com:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true ******** ******** -Dsonar.host.url=http://sonar.mycompany.com/
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] apps-thor
[INFO] thor-models
[INFO] thor-service-wrapper
[INFO] thor-web
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building apps-thor 1.6.6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
[WARNING] o com.mycompany.apps:thor-models:jar:1.6.6-SNAPSHOT (compile)
[WARNING] Try running the build up to the lifecycle phase "package"
[WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
[WARNING] o com.mycompany.apps:thor-service-wrapper:jar:1.6.6-SNAPSHOT (compile)
[WARNING] o com.mycompany.apps:thor-models:jar:1.6.6-SNAPSHOT (compile)
[WARNING] Try running the build up to the lifecycle phase "package"
[INFO] 
[INFO] --- sonar-maven-plugin:2.0:sonar (default-cli) @ apps-thor ---
[INFO] Sonar version: 3.5.1
     ...
[INFO] [11:21:36.714] Execute org.apache.maven.plugins:maven-surefire-plugin:2.10:test...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building thor-web 1.6.6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.379s
[INFO] Finished at: Tue Aug 06 11:21:37 MDT 2013
[INFO] Final Memory: 29M/194M
[INFO] ------------------------------------------------------------------------
[INFO] [11:21:37.563] Execute org.apache.maven.plugins:maven-surefire-plugin:2.10:test done: 849 ms
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] apps-thor ..................................... FAILURE [28.109s]
[INFO] thor-models ....................................... SKIPPED
[INFO] thor-service-wrapper .............................. SKIPPED
[INFO] thor-web .......................................... FAILURE [0.457s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.809s
[INFO] Finished at: Tue Aug 06 11:21:37 MDT 2013
[INFO] Final Memory: 19M/194M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project thor-web: Could not resolve dependencies for project com.mycompany.apps:thor-web:war:1.6.6-SNAPSHOT: The following artifacts could not be resolved: com.mycompany.apps:thor-service-wrapper:jar:1.6.6-SNAPSHOT, com.mycompany.apps:thor-models:jar:1.6.6-SNAPSHOT: Failure to find com.mycompany.apps:thor-service-wrapper:jar:1.6.6-SNAPSHOT in http://archiva.mycompany.com/repository/mycompany/ was cached in the local repository, resolution will not be reattempted until the update interval of mycompany has elapsed or updates are forced -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project thor-web: Could not resolve dependencies for project com.mycompany.apps:thor-web:war:1.6.6-SNAPSHOT: The following artifacts could not be resolved: com.mycompany.apps:thor-service-wrapper:jar:1.6.6-SNAPSHOT, com.mycompany.apps:thor-models:jar:1.6.6-SNAPSHOT: Failure to find com.mycompany.apps:thor-service-wrapper:jar:1.6.6-SNAPSHOT in http://archiva.mycompany.com/repository/mycompany/ was cached in the local repository, resolution will not be reattempted until the update interval of mycompany has elapsed or updates are forced
.....
Sonar analysis completed: FAILURE
Build step 'Sonar' changed build result to FAILURE
Build step 'Sonar' marked build as failure
Sending e-mails: 
Notifying upstream projects of job completion
Finished: FAILURE

James Nord (jnord)

unread,
Aug 7, 2013, 4:39:21 AM8/7/13
to jenkins...@googlegroups.com

Hi Jeff

 

(Disclaimer – IMHO Sonar is evil as it makes builds unreproducible as build config is stored outside of the build, it doesn’t build things it needs so can test/report not what users are expecting)

 

However the case below is the sonar plugin attempting to resolve the snapshot versions of your jars.

These have not yet been built (and won’t be built in your reactor) and so sonar is trying to resolve them from the repository (where they don’t exist – see my disclaimer above).

 

sonar:sonar

Full name:

org.codehaus.mojo:sonar-maven-plugin:2.1:sonar

Description:

Analyze project. SonarQube server must be started.

Attributes:

·         Requires a Maven project to be executed.

·         Executes as an aggregator plugin.

·         Requires dependency resolution of artifacts in scope: test.

 

So this is a question you should ask on the Maven users list.

 

/James

 

 

 

 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michaël Pailloncy

unread,
Aug 7, 2013, 5:01:11 AM8/7/13
to jenkins...@googlegroups.com
I've faced with the same problem.
I found two possibilities :
 - use a parameter to skip sonar analysis during release (see advanced options of Sonar post build action)
 - split normal build/release process and sonar analysis in two different jobs 




2013/8/7 James Nord (jnord) <jn...@cisco.com>

Jeff

unread,
Aug 7, 2013, 11:53:51 AM8/7/13
to jenkins...@googlegroups.com
Thanks...I updated the post-build settings to skip SONAR if IS_M2RELEASEBUILD is defined (haven't tried it yet).  I would prefer a separate job but I haven't quite worked out how to do that.  

The job would need to run in the context of an existing workspace wouldn't it?  Unless every project has 2 jobs, one that runs normal builds and one that runs Sonar.  With 60+ projects (and growing) I don't really want to duplicate each, but I'm not sure how to work out a shared parameterized job.

How do you or others do it?

Michaël Pailloncy

unread,
Aug 7, 2013, 12:48:30 PM8/7/13
to jenkins...@googlegroups.com
In my compagny, we've decided to create a separated job for Sonar analysis. The main raison was that we didn't want to start a Sonar analysis for each build (time consuming). So the best solution was to create another job with a more limited SCM poll (every 4 hours). Like that, we ensure that a Sonar analysis is performed only if the code has been modified.

Yes, Sonar analysis need an existing project, so we've configured the Sonar job to invoke a Maven build with "clean verify sonar:sonar ...".
The counterpart is a higher consumption of disk space (but not necessarily so high because Sonar jobs are started only if changes were made to the code associated to the project).

To migrate all of our jobs in one shot, I've created a groovy script to migrate all jobs (freestyle) : https://gist.github.com/mpapo/204d8a1216a2d717e08e
It's based on an existing Sonar job which serves as template. This script must be adapted to your needs.

Hope this help.


2013/8/7 Jeff <preda...@gmail.com>

Michaël Pailloncy

unread,
Aug 7, 2013, 12:58:17 PM8/7/13
to jenkins...@googlegroups.com
*company sorry :-)

Cheers!


2013/8/7 Michaël Pailloncy <mpap...@gmail.com>
Reply all
Reply to author
Forward
0 new messages