RPM JENKINS_JAVA_OPTIONS are inlined within a single Java argument starting with 2.303.2.3

Article ID:4408416409627
2 minute readKnowledge base

Issue

In release 2.303.2.3, a new array-based syntax was introduced for JENKINS_JAVA_OPTIONS in order to support arguments that contain spaces. This improvement caused a regression for any configuration variables that were strings. The new array-based syntax is a more robust and maintainable syntax going forward, but if you upgrade to release 2.303.2.3 through 2.303.2.6, you will need to modify your configuration file in /etc/sysconfig as documented below.

This can cause your instance to fail to start after upgrading, or some of your startup options will not be taking effect (which will cause unexpected changes in behaviour after the upgrade).

Workaround

If using release 2.303.2.3 through 2.303.2.6, you must migrate your JENKINS_JAVA_OPTIONS to the new array-based syntax regardless if your arguments have spaces in them or not.

Resolution

With product release 2.303.3.3, if your JENKINS_JAVA_OPTIONS does not contain spaces, you can use either strings or array-based syntax. If your JENKINS_JAVA_OPTIONS contains spaces, you must use the new array-based syntax.

If running 2.303.3.3 or newer, it’s still a best practice to use the array-based syntax, as it makes it simpler to comment out an argument that you’d like to disable.

Array-based syntax

The syntax required for the JENKINS_JAVA_OPTIONS variable has changed in the files:

/etc/sysconfig/cloudbees-core-oc (CloudBees Core on traditional platforms - Operations Center)
/etc/sysconfig/cloudbees-core-cm (CloudBees Core on traditional platforms - Client Controller)
/etc/sysconfig/jenkins-oc (CloudBees Jenkins Platform - Operations Center)
/etc/sysconfig/jenkins (CloudBees Jenkins Platform - Client Controller)

Previously, the syntax for JENKINS_JAVA_OPTIONS was (your Java options will be different, this is just an example):

JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-same-origin allow-scripts;style-src 'unsafe-inline' _;script-src 'unsafe-inline' _;\" -Dcom.cloudbees.jenkins.ha=false"

Starting with release 2.303.2.3, you can use the following array-based syntax:

JENKINS_JAVA_OPTIONS=("-Djava.awt.headless=true")
JENKINS_JAVA_OPTIONS+=("-Dhudson.model.DirectoryBrowserSupport.CSP=\"sandbox allow-same-origin allow-scripts;style-src 'unsafe-inline' _;script-src 'unsafe-inline' _;\"")
JENKINS_JAVA_OPTIONS+=("-Dcom.cloudbees.jenkins.ha=false")

Tested product/plugin versions

CloudBees CI on traditional platforms version 2.303.2.5 installed via RPM

References

  • BEE-9272: all JENKINS_JAVA_OPTIONS are inlined within a single java argument