I can't get module exclusion to work with Jenkins maven plugin, see the output below:
07:11:53 Executing Maven: -B -f /home/jenkins/.jenkins/workspace/my_project/pom.xml clean cobertura:cobertura install -P nogpl,ci -pl -gotham/java/dev-server -X -e
07:12:00 Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
07:12:04 Maven home: /home/jenkins/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/jenkins_maven
07:12:06 Java version: 1.7.0_60, vendor: Oracle Corporation
07:12:06 Java home: /usr/local/java/jdk1.7.0_60/jre
07:12:06 Default locale: en_US, platform encoding: UTF-8
07:12:06 OS name: "linux", version: "3.5.0-23-generic", arch: "amd64", family: "unix"
07:12:06 [INFO] Error stacktraces are turned on.
07:12:06 [DEBUG] Reading global settings from /home/jenkins/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/jenkins_maven/conf/settings.xml
07:12:06 [DEBUG] Reading user settings from /home/jenkins/.m2/settings.xml
07:12:06 [INFO] Scanning for projects...
07:12:06 [ERROR] Could not find the selected project in the reactor: -gotham/java/dev-server -> [Help 1]
It works when I copy the command into a pre-build shell step in the same Job:
07:20:27 + mvn -B -f /home/jenkins/.jenkins/workspace/my_project/pom.xml clean cobertura:cobertura deploy -P nogpl,ci -pl -gotham/java/dev-server -X -e
07:20:27 Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
07:20:27 Maven home: /home/jenkins/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/jenkins_maven
07:20:27 Java version: 1.7.0_60, vendor: Oracle Corporation
07:20:27 Java home: /usr/local/java/jdk1.7.0_60/jre
07:20:27 Default locale: en_US, platform encoding: UTF-8
07:20:27 OS name: "linux", version: "3.5.0-23-generic", arch: "amd64", family: "unix"
07:20:30 [INFO] Error stacktraces are turned on.
07:20:30 [DEBUG] Reading global settings from /home/jenkins/.jenkins/tools/hudson.tasks.Maven_MavenInstallation/jenkins_maven/conf/settings.xml
07:20:30 [DEBUG] Reading user settings from /home/jenkins/.m2/settings.xml
07:20:30 [DEBUG] Using local repository at /home/jenkins/.m2/repository
07:20:30 [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/jenkins/.m2/repository
07:20:30 [INFO] Scanning for projects...
[...]
07:20:31 [INFO] ------------------------------------------------------------------------
07:20:31 [INFO] Reactor Build Order:
In the stack trace you can see that hudson-maven agent is interfereing. Notable differences are:
org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard
and shell uses ...launchEnhanced
org.apache.maven.DefaultMaven.trimSelectedProjects
but shell fails in ...trimExcludedProjects
The full stack trace is:
Could not find the selected project in the reactor: -gotham/java/dev-server -> [Help 1]
org.apache.maven.MavenExecutionException: Could not find the selected project in the reactor: !gotham/java/dev-server
at org.apache.maven.DefaultMaven.trimSelectedProjects(DefaultMaven.java:886)
at org.apache.maven.DefaultMaven.createProjectDependencyGraph(DefaultMaven.java:820)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:268)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.jvnet.hudson.maven3.launcher.Maven32Launcher.main(Maven32Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven32Main.launch(Maven32Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:136)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:71)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Compare that with failure stack trace when I on purpose try to exclude a non-existent module in pre-build step:
org.apache.maven.MavenExecutionException: Could not find the selected project in the reactor: gotham/java/dev-server2
at org.apache.maven.DefaultMaven.trimExcludedProjects(DefaultMaven.java:977)
at org.apache.maven.DefaultMaven.createProjectDependencyGraph(DefaultMaven.java:821)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:268)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
I've also tried using the -pl !gotham/java/dev-server
syntax and also tried not putting a space after pl
like -pl!gotham/java/dev-server
Note: there is a small difference between those runs - the one executed directly from shell is Using local repository at /home/jenkins/.m2/repository
while the one executed via plugin isn't. I'm not sure what is the cause but I doubt it's related
I'm using Jenkins version 1.540 with the maven-project plugin v. 2.8 (lastest)
Apparently this indeed isn't suported - https://issues.jenkins-ci.org/browse/JENKINS-26472