How to set a JVM option in Jenkins globally for every job?
Asked Answered
V

4

22

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.

Virgule answered 17/10, 2012 at 8:52 Comment(1)
Which application server do you deploy the Jenkins? Tomcat, GF or other?Tadpole
D
19

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,

Dzungaria answered 17/10, 2012 at 10:41 Comment(3)
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.Virgule
This solved my issue with OSX 10.8.3 running Jenkins 1.514 and JDK 1.6.0_45Fairfax
Seemed to be the only thing that worked for me. Pretty easy to go wrong with this one.Mueller
E
7

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)

Equity answered 14/1, 2016 at 14:41 Comment(0)
T
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.

Tadpole answered 17/10, 2012 at 10:8 Comment(0)
B
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.

Banff answered 4/5, 2015 at 10:21 Comment(1)
The config.xml would be good except even today I can't locate documentation for it. I will try the groovy method.Punk

© 2022 - 2024 — McMap. All rights reserved.