[2.289.2.2] Upgrade/Installation to 2.289.2.2 on CloudBees CI on Traditional through .rpm fails on startup if a Java Option contains spaces

Article ID:4404272722075
2 minute readKnowledge base

Issue

  • After upgrade CloudBees CI to version 2.289.2.2 or later using RPM, the service fails to start and shows the following:

cloudbees-core-cm[xxxx]: Error: Could not find or load main class <element>

Explanation

Any installation or upgrade to CloudBees CI on traditional platforms 2.289.2.2 through RPM fails in case the configuration file /etc/sysconfig/cloudbees-core-[cm|oc] contains a java option with spaces in JENKINS_JAVA_OPTIONS. A typical use case is the system property hudson.model.DirectoryBrowserSupport.CSP that usually contains spaces, for 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' _;\""

This would cause the service to fail to start with the following output in systemctl logs.

cloudbees-core-cm[xxxx]: Error: Could not find or load main class allow-same-origin
systemd[1]: cloudbees-core-cm.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Unit cloudbees-core-cm.service entered failed state.
systemd[1]: cloudbees-core-cm.service failed.
systemd[1]: Started cloudbees-core-cm.
systemd[1]: cloudbees-core-cm.service: main process exited, code=exited, status=2/INVALIDARGUMENT
  • BEE-7072: Spaces in configuration for systemd break java startup.

Resolution

This issue is fixed after upgrading your instance to at least version 2.303.2.5, to prepare for upgrading, please reach out to us so we can help plan your next upgrade via an Assisted Update.

Please be aware that you may be impacted by RPM JENKINS_JAVA_OPTIONS are inlined within a single Java argument starting with 2.303.2.3 when you upgrade.

Workaround

Until you are able to upgrade to a version with the fix, the workaround is to remove the system property that contains spaces from the configuration file /etc/sysconfig/cloudbees-core-[cm|oc] and add that system property explicitly to the service script /usr/bin/cloudbees-core-[cm|oc].

Remove the system property from the Configuration File

  • Edit the /etc/sysconfig/cloudbees-core-cm on the Controller host (or /etc/sysconfig/cloudbees-core-oc for Operations Center)

  • Locate the line where the JENKINS_JAVA_OPTIONS=... are set:

      JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -D<optionName>=\"<value With Spaces>\""
  • Remove the system property that contains spaces (in this example -D<optionName>=\"<value With Spaces>\")

      JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"

Add the system property to the Script File

  • Edit the /usr/bin/cloudbees-core-cm on the Controller host (or /usr/bin/cloudbees-core-oc for Operations Center)

  • Locate the line that execute the java command (this should be the last line of the file)

      $JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -jar $JENKINS_WAR $PARAMS
  • Add the system property that contains spaces before -jar:

      $JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -D<optionName>="<value With Spaces>" -jar $JENKINS_WAR $PARAMS

Restart the service

systemctl restart cloudbees-core-[cm|oc]