20

I've recently installed a new JDK (1.7u9), and I got some very strange VerifyErrors. In a thread I found that it could help me if I use a -XX:-UseSplitVerifier magic switch for the compilation.

What I would like to do is to set this Java option globally in Jenkins, but haven't found any configurations for it. Can someone help me out how can I do this?

The closest thing I was able to come up with is to set the argument through Maven, but I have to do it for each project configuration - and I'd like to avoid that.

Thanks in advance.

Community
  • 1
  • 1
rlegendi
  • 10,466
  • 3
  • 38
  • 50

4 Answers4

18

Under the main menu item Manage Jenkins->Configure System you can set it in the box for Global MAVEN_OPTS.

It is a bit unclear whether you want the option turned on for the Jenkins container itself or only the jobs running in it, but if the latter and you're only running maven jobs, that's what I would do.

Cheers,

Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
  • Thanks, I believe this will be the solution. I wanted to set JVM arguments for different JDKs in Jenkins, but wasn't able to locate such settings. However, I can define it for Maven globally, that's enough. – rlegendi Oct 17 '12 at 16:38
  • This solved my issue with OSX 10.8.3 running Jenkins 1.514 and JDK 1.6.0_45 – krams May 08 '13 at 00:33
  • Seemed to be the only thing that worked for me. Pretty easy to go wrong with this one. – JHollanti Oct 02 '15 at 08:33
5

If you deploy the Jenkins to the Tomcat or Glassfish, I would like to suggest you to set further configuration as the following:-

The Tomcat

Set the environment variable named CATALINA_OPTS, e.g.

SET CATALINA_OPTS="-XX:-UseSplitVerifier"
EXPORT CATALINA_OPTS

The Glassfish

Edit the [your_domain]/config/domain.xml

<java-config ....>
    ....
    <jvm-options>-XX:-UseSplitVerifier</jvm-options>
</java-config>

Anyhow if you deploy it to another application server, please refer to your application server administrator guide to configure further JVM options.

UPDATED:

If you only would like to apply this JVM option to the Maven project, please set the environment variable named MAVEN_OPTS, e.g.

SET MAVEN_OPTS="-XX:-UseSplitVerifier"
export MAVEN_OPTS

I hope this may help.

Regards,

Charlee Ch.

Charlee Chitsuk
  • 8,847
  • 2
  • 56
  • 71
5

On Windows there's a jenkins.xml in Jenkins home directory. Simply add the required JVM options under arguments tag:

<arguments>
    -Xrs -Xmx256m -XX:-UseSplitVerifier 
    -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle 
    -jar "%BASE%\jenkins.war" --httpPort=8080
</arguments>

For most of the Linux distributions, modify JENKINS_ARGS inside file: /etc/default/jenkins (or jenkins-oc)

For CentOS, modify JENKINS_JAVA_OPTIONS inside file: /etc/sysconfig/jenkins (or jenkins-oc)

Noam Manos
  • 15,216
  • 3
  • 86
  • 85
0

Apparently, the only way to set system-wide JVM properties in Jenkins is with a Groovy Script .

Create a init.groovy.d in Jenkins home and place a groovy file in it (load-properties.groovy). In the Groovy script, set system properties programmatically (see link above for details):

       props.each { key, value ->
        System.setProperty(key, value)

The above solution saved my day as I needed to disable jsse.enableSNIExtension during SCM checkout and it should be available to the SVN plugin, not to Maven.

There's a config.xml file with jdks/jdk/properties XML tags, but it's undocumented.

Agustí Sánchez
  • 10,455
  • 2
  • 34
  • 25
  • The config.xml would be good except even today I can't locate documentation for it. I will try the groovy method. – BenDavid Oct 20 '20 at 17:56