Changing the JRE used by CloudBees products on Windows

Issue

Due to changes in the Oracle license agreement CloudBees products are changing to include OpenJDK java executables. With this change, some customers will want to continue using Oracle releases.

Environment

Resolution

The Java executable to use for a CloudBees product is defined in the jenkins.xml file in the $JENKINS_HOME directory. In order to change which JRE is used, this file must be editted. The following steps will make this change:

  1. Backup the jenkins.xml before making any changes.
  2. Open the file to edit.
  3. Locate the service tag in the file and under that, the executable tag.
  4. Edit the contents of the executable tag and replace %BASE%\jre\bin\java with the full path of the java executable of the JRE or JDK to be used.
  5. Save this modified file.
  6. Restart the instance to enact the change.

See the example of a system on CloudBees Core on traditional Platforms Client Master 2.222.4.3.
The line to change can be found on line 10 of this example file.

<service>
  <id>CloudBeesCoreOC</id>
  <name>Jenkins</name>
  <description>This service runs Jenkins automation server.</description>
  <env name="JENKINS_HOME" value="%BASE%"/>
  <!--
    if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
    The following value assumes that you have java in your PATH.
  -->
  <executable>%BASE%\jre\bin\java</executable>
  <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar -Dcb.distributable.name=MSI -Dcb.distributable.commit_sha=d0fff650a006d3d5d717de88b6220fb05f7ce01e "%BASE%\cloudbees-core-oc.war" --httpPort=8888 --webroot="%BASE%\war"</arguments>
  <!--
    interactive flag causes the empty black Java window to be displayed.
    I'm still debugging this.
  <interactive />
  -->
  <logmode>rotate</logmode>

  <onfailure action="restart" />
  
  <!-- 
    In the case WinSW gets terminated and leaks the process, we want to abort
    these runaway JAR processes on startup to prevent corruption of JENKINS_HOME.
    So this extension is enabled by default.
  -->
  <extensions>
    <!-- This is a sample configuration for the RunawayProcessKiller extension. -->
    <extension enabled="true" 
               className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension"
               id="killOnStartup">
      <pidfile>%BASE%\jenkins.pid</pidfile>
      <stopTimeout>10000</stopTimeout>
      <stopParentFirst>false</stopParentFirst>
    </extension>
  </extensions>
  
  <!-- See the referenced examples for more options -->
  
</service>

You can confirm that the new Java executable is being used by navigating to Manage Jenkins -> System Information. The java.home and the java.vendor fields there should show the new Java JRE or JDK.

Tested product/plugin versions

  • Managed Masters - 2.222.4.3 and 2.204.3.7
  • Client Masters - 2.222.4.3 and 2.204.3.7
  • Oracle JDK 8
  • OpenJDK 8

References

Have more questions?

0 Comments

Please sign in to leave a comment.