Upgrade to Java 25

When upgrading the JVM used to run Jenkins from Java 21 to Java 25, there are some details you should know and precautions you should take. NOTE: Java 25 is supported as of LTS 2.541.1 and Jenkins Weekly 2.534.

Back up Jenkins

As with any upgrade, we recommend:

  1. Backing up JENKINS_HOME.

  2. Testing the upgrade with your backup.

  3. After all required tests pass, execute the upgrade on your production controller.

Upgrade the Jenkins Java version to Java 25

To verify the Java version currently used in your controller:

  1. Navigate to Manage Jenkins and then select System Information in the Status Information section.

  2. On the System Properties tab, locate the java.runtime.version and reveal the hidden value to display your current Java version.

To verify the Java version currently used in your agent:

  1. Select an agent name from the Build Executor Status widget and then select System Information.

  2. Locate the java.runtime.version and reveal the hidden value to display the current Java version.

The checkNodes script determines what version of Java is running the controller process, along with the version of the agent that’s associated with that controller. The script then checks the version of Java that is on the agent. When these values are returned, OK means that the agent Java version matches the controller Java version. Otherwise, the result displays the expected Java version and the version found instead.

To run the checkNodes script:

  1. Navigate to Manage Jenkins and select Script Console from the Tools and Actions section.

  2. Copy the following script into the empty text box and select Run:

/*** BEGIN META {
 "name" : "Check Nodes Version",
 "comment" : "Check the .jar version and the java version of the Nodes against the Master versions",
 "parameters" : [ ],
 "core": "1.609",
 "authors" : [
 { name : "Allan Burdajewicz" }
 ]
 } END META**/

import hudson.remoting.Launcher
import hudson.slaves.SlaveComputer
import jenkins.model.Jenkins

def expectedAgentVersion = Launcher.VERSION
def expectedJavaVersion = System.getProperty("java.version")
println "Master"
println " Expected Agent Version = '${expectedAgentVersion}'"
println " Expected Java Version = '${expectedJavaVersion}'"
Jenkins.instance.getComputers()
        .findAll { it instanceof SlaveComputer }
        .each { computer ->
    println "Node '${computer.name}'"
    if (!computer.getChannel()) {
        println " is disconnected."
    } else {
        def isOk = true
        def agentVersion = computer.getSlaveVersion()
        if (!expectedAgentVersion.equals(agentVersion)) {
            println " expected agent version '${expectedAgentVersion}' but got '${agentVersion}'"
            isOk = false
        }
        def javaVersion = computer.getSystemProperties().get("java.version")
        if (!expectedJavaVersion.equals(javaVersion)) {
            println " expected java version '${expectedJavaVersion}' but got '${javaVersion}'"
            isOk = false
        }

        if(isOk) {
            println " OK"
        }
    }
}
return;

Upgrade to Java 25 on your Jenkins controller

To upgrade Java on your Jenkins controller:
  1. Stop the Jenkins controller with systemctl stop jenkins.

  2. Install the corresponding Java version with dnf -y install temurin-25-jdk or with the package manager your system uses.

  3. Check the Java version with java -version.

  4. Change the default Java for the system by running update-alternatives --config java and then enter the number that corresponds to Java 25, for example 2 if that is the correct option.

  5. Verify the Java version on the Jenkins controller with java -version.

  6. Restart Jenkins with systemctl restart jenkins.

    Remove any older Java versions if they are no longer needed.

Upgrade Jenkins

To upgrade Jenkins, as well as the JVM, we recommend you:

  1. Back up JENKINS_HOME.

  2. Stop the Jenkins controller.

  3. Upgrade the JVM on which Jenkins is running.

    • Use a package manager to install the new JVM.

    • Ensure the default JVM is the newly installed version.

      • If it is not, run systemctl edit jenkins, and set either the JAVA_HOME environment variable or the JENKINS_JAVA_CMD environment variable.

  4. Upgrade Jenkins to the most recent version.

    • How you upgrade Jenkins is dependent upon your original Jenkins installation method.

      We recommend that you use the package manager of your system (such as apt or yum).
  5. Validate the upgrade to confirm that all plugins and jobs are loaded.

  6. Upgrade the required plugins.

When upgrading the Java version for Jenkins and the JVM, it is important to upgrade all plugins that support Java 25. Plugin upgrades assure compatibility with the most recent Jenkins releases.

If you discover a previously unreported issue, please let us know. Refer to our issue reporting documentation for guidance.

JVM version on agents

Agents don’t need to run the exact same Java version as the controller, they just need to run at least the minimum Java version required by the controller. When upgrading your Jenkins controller to Java 25, make sure all agents are running a Java version supported by your Jenkins release.

Validating the version of each agent can be done with the Versions Node Monitors plugin. This plugin provides information about the JVM version of each agent on the node management screen of your Jenkins controller. You can configure this plugin to automatically disconnect agents running an unsupported Java version.

Upgrade to Java 25 on agents

To upgrade Java on your Jenkins controller:
  1. In the command line, log into the agent.

  2. Enter dnf -y install temurin-25-jdk, or use the appropriate command for your package manager.

  3. Check your java version using java -version.

  4. Change the default Java version using update-alternatives --config java and then enter the selection corresponding to Java 25.

  5. Verify the Java version has been updated with java -version.

  6. From the agent page in your Jenkins controller, select Disconnect.

  7. After disconnecting the agent, reconnect it by selecting Bring this node back online and then selecting Launch agent.

    Also remove any older Java versions that are no longer needed on your agents to free up system resources and avoid potential conflicts.


Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.