How to add Java arguments to Jenkins in CloudBees Jenkins Enterprise ?

Article ID:115000532471
3 minute readKnowledge base

Issue

  • Don’t know how to add/update Java arguments to Jenkins in CloudBees Jenkins Enterprise.

Resolution

In CloudBees Jenkins Enterprise, the Java Options are passed to the JVM running Jenkins via the JAVA_OPTS Environment Variable set to the container running Jenkins.

  • For Operations Center, the configuration is managed via the CJE project:

    • the Java Options must be updated and applied cje prepare cjoc-update

  • For Managed controllers, the configuration is managed by Operations Center:

    • the Java Options must be updated in the Managed controller’s item configuration

    • the configuration must be applied by restarting the Managed controller from Operations Center: this will update the cjoc Marathon application that will re-provision the Operations Center container with the updated values

Managed controllers

For Java Heap size (-Xmx), using a combination of:

  • Jenkins controller 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 controller Memory in MB" to use as heap for the Jenkins controller JVM. This must be a decimal between 0 and 1. Values over 0.7 are not recommended and can cause controller restarts when running out of memory.

For any others, the Java Options of Managed controllers can be set in different ways:

  • Java Options in the Managed controller configuration (per controller configuration)

  • System Properties in the Managed controller configuration (per controller configuration)

When managing many controllers, a better strategy is to configure or enforce defaults:

  • Default Java Options in the Mesos controller Provisioning global configuration (default options for newly created controllers)

  • Default System Properties in the Mesos controller Provisioning global configuration (default system properties for newly created controllers)

  • Global Java Options in the Mesos controller Provisioning global configuration (enforced options for all provisioned controllers)

Java Options may contain System Properties, they are prefixed with -D. System Properties however cannot contain Java Arguments such as -XshowSettings:vm or -XX:*.

controller Java Options

Go to Operations Center Dashboard and click on Configure on the Managed controller you want to add the Java argument.

mmconfiguration

Once here, you can add your Java arguments under Provisioning > Java Options (separated with blank spaces, not line breaks).

controller System Properties

Go to Operations Center Dashboard and click on Configure on the Managed controller you want to add the Java argument.

mmconfiguration

Once here, you can add your System Properties under Provisioning > System Properties (separated with line breaks, not blank spaces). For example:

hudson.slaves.NodeProvisioner.initialDelay=0
hudson.DNSMultiCast.disabled=true

controller Default Java Options

controller Default Java Options are the default Java Options added to a Managed controller configuration when it is created. They are configurable in Operations Center.

To configure those Default Java Options, go under Manage Jenkins  Configure System  Mesos controller Provisioning [Advanced > Default Java Options].

Changes made to the Default Java Options are not reflected in the configuration of existing Managed controller

controller Default System Properties

controller Default System Properties are the default System Properties added to a Managed controller configuration when it is created. They are configurable in Operations Center.

To configure those Default System Properties Options, go under Manage Jenkins  Configure System  Mesos controller Provisioning [Advanced > Default System Properties].

Changes made to the Default System Properties are not reflected in the configuration of existing Managed controller

controller Global Java Options

controller Global Java Options are Java options that are enforcibly added to every Managed controller deployment and not configurable from the UI. Those Java Options are automatically appended to the Managed controller’s JAVA_OPTS environment variable during provisioning. They are enforced to all managed controllers and not configurable from the UI.

To configure those Global Java Options, go under Manage Jenkins  Configure System  Mesos controller Provisioning [Advanced > Global Java Options].

Changes to the Global Java Options are reflected to every Managed controller when re-provisioned