9

I installed Jenkins 1.512 on CentOS (info as follows) and configured it to work with apache-maven-3.0.4.

Linux server.masstermmind.com 2.6.32-358.2.1.el6.x86_64 #1 SMP Tue Mar 12 14:18:09 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux

I was actually trying to solve a problem where Maven complained about missing vaule of jbossHome parameter in the pom.xml file. So, I decided to debug Maven by putting the -X option in Jenkins MAVEN_OPTS. But it complained that I put in an incorrect Java argument:

The -X options are non-standard and subject to change without notice.

It turned out Jenkins thinks I put in an argument for Java. Later I found out the command generated by Jenkins was like the following:

/usr/java/jdk1.7.0_17/bin/java -X -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/usr/share/apache-maven-3.0.5/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/share/apache-maven-3.0.5 /var/cache/jenkins/war/WEB-INF/lib/remoting-2.23.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar 35460

But what I found out from running mvn, it generated the following Java line, and the "-X" was placed at the end, correctly.

/usr/java/jdk1.7.0_17/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/usr/share/apache-maven-3.0.5/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/share/apache-maven-3.0.5 /var/cache/jenkins/war/WEB-INF/lib/remoting-2.23.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar -X

Could you share an approach how I can fix this or it is a Jenkins bug?

jszumski
  • 7,430
  • 11
  • 40
  • 53
Student_T
  • 93
  • 1
  • 1
  • 3

1 Answers1

11

AFAIU, it is a Jenkins normal behavior to put the MAVEN_OPTS after the java command. Since the purpose of the MAVEN_OPTS is the environment variable in the user variables to specify JVM properties.

I would suggest you to put the -X parameter at the Jenkins Maven Job itself. At the Build ---> Goals and options, you may click the question mark link at the end of the textbox. It will give you the following: -

Specifies the goals to execute, such as "clean install" or "deploy". This field can also accept any other command line options to Maven, such as "-e" or "-Dmaven.test.skip=true".

Then the suitable value for Build ---> Goals and options should be something like clean install -X.

I hope this may help.

Charlee Chitsuk
  • 8,847
  • 2
  • 56
  • 71
  • Hi Charlee - Thanks so much for the pointer. After I put the -X in the Jenkins Maven Job as you said it worked. Really appreciate your help! – Student_T Apr 27 '13 at 18:04
  • 1
    That works. But we have a 1000 jobs and it's not a valid solution to add some parameter to every single job... isn't there a way to globally set a JVM property for Maven builds? – dokaspar Sep 12 '16 at 13:22
  • Manage Jenkins->Configure System - See https://stackoverflow.com/questions/12930529/how-to-set-a-jvm-option-in-jenkins-globally-for-every-job – Xdg Feb 03 '20 at 06:04