How to add Java arguments to Jenkins on CloudBees CI Modern?

Article ID:360045597912
3 minute readKnowledge base

Issue

  • Don’t know how to add/update Java arguments to Jenkins in CloudBees CI Modern

Resolution

In CloudBees CI on Modern Platforms, the Java Options are passed to the JVM running Jenkins via the JAVA_OPTS Environment variable set in the Pod spec. The Pod is managed by a workload object, and it is, therefore, the workload object that must be updated. When the corresponding workload object is updated, the managed Pod is deleted, and a new pod is created with the updated values.

  • For the Operations Center, the configuration is managed via Helm:

    • the Java Options must be updated in the configuration file (i.e. values.yaml with Helm)

    • the configuration must be applied (i.e. helm upgrade with Helm): this will update the Operations Center StatefulSet and apply the changes made

  • For Managed controllers, the configuration is managed by the 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 recreate the controller’s StatefulSet or Deployment and apply the changes made

Operation Center

The Java Options of the Operations Center must be added to the JAVA_OPTS environment variable of the cjoc statefulset.

You need to add the Java arguments to the OperationsCenter.JavaOpts attribute (e.g., --set OperationsCenter.JavaOpts). For example:

OperationsCenter: JavaOpts: >- -Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.DNSMultiCast.disabled=true ...

Then apply the update configuration - for example helm upgrade cloudbees-core cloudbees/cloudbees-core -f values.yaml --version 3.15.0.

Managed controllers

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 Kubernetes controller Provisioning global configuration (default options for newly created controllers)

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

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

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

controller Java Options

Go to the Operations Center Dashboard and click on Configure on the Managed controller to which 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 the Operations Center Dashboard and click on Configure on the Managed controller to which 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 the Operations Center.

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

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

Enforce the controller Default Java Options

To enforce those Default Java Options, add the environment variable MASTER_JAVA_OPTIONS to the Operations Center StatefulSet. In that case the options will not be configurable from the UI. This is currently not supported via Helm.

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  Kubernetes 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.

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

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

Enforce the controller Global Java Options

To enforce those Global Java Options, add the environment variable MASTER_GLOBAL_JAVA_OPTIONS to the Operations Center StatefulSet. In that case the options will not be configurable from the UI.

You need to add the Java arguments to the Master.JavaOpts attribute (e.g., --set Master.JavaOpts). For example:

Master: JavaOpts: >- -Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.DNSMultiCast.disabled=true ...

Then apply the update configuration - for example helm upgrade cloudbees-core cloudbees/cloudbees-core -f values.yaml --version 3.15.0.