How to add Java arguments to Jenkins?


  • Don’t know how to add/update Java arguments to CloudBees Jenkins Platform or Managed Master



It depends on the way you ran Jenkins.

Note: The Jenkins System and Remoting Properties are added as Java Arguments.

Testing the properties

IMPORTANT: This type of setting is not persistent thus the property default values will be reset after the next restart.

In the Script Console, depending on the property setting.

Most of the Jenkins properties are static, therefore you can update its value like in the following examples:


There are some exceptions like the JENKINS-35484 which makes use of the Jenkins SystemProperties

Traditional Platform

Running Jenkins inside Jetty Winstone container

This is the default way to run Jenkins if you installed Jenkins using system packages.

In order to pass Java arguments to Jenkins you need to change the Jenkins service configuration file. It requires root access to the machine.

In CloudBees Jenkins Enterprise, you can find this file under:

  • /etc/default/jenkins: location for most of the Linux distributions.
  • /etc/sysconfig/jenkins: location for RedHat/CentOS distribution.
  • C:\Program Files\Jenkins\jenkins.xml: default location for Windows.

In CloudBees Jenkins Operations Center, you can find this file under:

  • /etc/default/jenkins-oc: location for most of the Linux distributions.
  • /etc/sysconfig/jenkins-oc: location for RedHat/CentOS distribution.
  • C:\Program Files\Jenkins-OC\jenkins.xml: default location for Windows.

Debian / Ubuntu based Linux distributions

If your configuration file is under /etc/default/ look for the argument JAVA_ARGS. It should look something like this:


Then, add the arguments:

JAVA_ARGS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"

RedHat Linux based distributions

If your configuration file is under /etc/sysconfig/ look for the argument JENKINS_JAVA_OPTIONS. It should look something like this:


Then, add the arguments:

JENKINS_JAVA_OPTIONS="-Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true"

Running Jenkins in Windows as a Service

If configuration file jenkins.xml is located under the Jenkins installation directory - commonly C:\Program Files\Jenkins\ or C:\Program Files\Jenkins-OC\. Then add the arguments into the <arguments> tag. It should look like this::

<arguments>-Xmx2048m -XX:MaxPermSize=512m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>

Running Jenkins inside Docker

The JAVA_OPTS should be passed to the container via --env JAVA_OPTS="..." like the following:

docker run --name myjenkins -p 8080:8080 -p 50000:50000 --env JAVA_OPTS="-Xmx2048m -XX:MaxPermSize=512m" jenkins

Note: With Docker, in terms of memory, other constraints apply.

Running Jenkins inside Tomcat

Use environment variable CATALINA_OPTS:

export CATALINA_OPTS="-DJENKINS_HOME=/path/to/jenkins_home/ -Xmx512m"

It is recommended to configure it in the script $CATALINA_BASE/bin/ (linux) or %CATALINA_BASE%\bin\setenv.bat (windows) that you’ll create to customize your application server.

Running Jenkins inside another JEE container

Please refer to the documentation of the container you are using.

Cloud Platform

CJE 1.x

Operation Center

How to add Java arguments to CJE Operations Center

Managed Masters

Go to Managed Master > Configuration > Provisioning > Advanced

  • For Java Heap size (-Xmx), using a combination of:
    • Jenkins Master Memory in MB: This is the amount of RAM that will be given to the container, expressed in megabytes according to the instance capabilities. For instance in AWS, see instance types.
    • JVM Max heap ratio: The ratio of the memory set under “Jenkins Master Memory in MB” to use as heap for the Jenkins master JVM. This must be a decimal between 0 and 1. Values over 0.7 are not recommended and can cause master restarts when running out of memory.
  • For any others: System Properties
    • Before 1.7.1 - just JAVA_OPTS. For instance: JAVA_OPTS=-XX:+PrintGCDetails.
    • Since 1.7.1 - JAVA_OPTS+[OTHER_VARIABLE]. For instance: JAVA_OPTS+MANAGED_MASTER =-XX:+PrintGCDetails.

CJE 2.x

Managed Masters

Managed Master > Configure > Java Options

Operation Center

List all your statefulset

$> kubectl get statefulsets
cjoc      1         1         11d

Edit cjoc statefulsets by

$> kubectl edit statefulsets cjoc

Then edit

      - env:
        - name: JAVA_OPTS
          value: -XshowSettings:vm -XX:MaxRAM=${MEM_LIMIT}m -XX:MaxRAMFraction=1 -XX:+PrintGCDetails
            -Dcb.IMProp.warProfiles=kubernetes.json -Dcb.IMProp.warProfiles.cje=kubernetes.json
            -Dhudson.lifecycle=hudson.lifecycle.ExitLifecycle -Dcom.cloudbees.jce.masterprovisioning.DockerImageDefinitionConfiguration.disableAutoConfiguration=true
            Core - Managed Master" -Dcom.cloudbees.jce.masterprovisioning.DockerImageDefinitionConfiguration.masterImage=cloudbees/cloudbees-core-mm:
Have more questions? Submit a request


  • 0
    Avi Kessner

    How can I update the statefulset yaml file, instead of editing the sts directly on the cluster?

Please sign in to leave a comment.