Jenkins Post Upgrade Issue

I upgraded Jenkins (Linux) 2.356 (JDK 1.8) to version 2.363 (JDK 11), controller is running fine I was able to login to the console. But, the 3 Linux agents went offline. I don’t want to upgrade agent Java version. All 3 are running on JDK 1.8. I am sure I missed something. Any help would be greatly appreciated.

I checked the log via the console. It says “Exception in thread main java.lang.UnsupportedClassVersionError: hudson/remoting/launcher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0.”

52.0 is Java 1.8, I cannot upgrade agent Java since the web applications are using Java 1.8 only. My understand is I can run controller and agent on different Java versions.

The same JDK is needed on the agent and the controller. The controllers sends Java classes to the agent. If the agent does not understand those Java classes, the agent won’t work.

https://www.jenkins.io/doc/administration/requirements/upgrade-java-guidelines/#jvm-version-on-agents

says:

All agents must be running on the same JVM version as the controller due to how controllers and agents communicate. If you’re upgrading your Jenkins controller to run on Java 11, you also need to upgrade the JVM on your agents.

The JVM that runs the agent can be different than other JVM’s installed on the agent computer. If a web application requires JDK 8, that does not prevent your running a Jenkins agent in JDK 11 on the same computer that hosts the JDK8 web application.

1 Like

explains how to use a different version of java for builds rather than running jenkins

Please check my initial post How to use two different versions of JDK
I thought agent can have different Java version.

agents can have another version installed, but the java running agent.jar needs to be the same as the controller. you can set JAVA_HOME and use a different version for builds though.

Please clarify with more details.

  1. Install Java 11 in all the agents
  2. How to run the agent.jar using JDK 11?
  3. How to force the Jenkins pipelines to use JDK 1.8?

Not sure how -->you<-- do this, it depends on your os, and setup, and all kinds of things. A quick google search for “$OS $DISTRO java 11” should help

Set JAVA_HOME, and/OR path to JDK 11, then run java -jar agent.jar

Setup JAVA_HOME/PATH on the env section of your agent configuration. Or use the jenkins tool system to choose different versions of java per job.

1 Like

Thanks. I installed the same version of JDK in one of the agent. It now has 2 version of JDK installed (1.8 and 11). I changed the JDK using ‘sudo alternatives --config java’ and issued a reboot. It now automatically connected to the controller. How do I use JDK 1.8 and run the application deployment pipeline? It’s still confusing me.

In the console ‘Node properties’ we defined the Environment variables for JAVA_HOME as /usr/java/latest. This symlink currently points to JDK11. Should I modify the symlink to point to JDK 1.8? OR should I add a JAVA_HOME in the Global Tool Configuration to point it to JDK 1.8 path? I don’t want to choose different versions of java per job.

I tried setting JAVA_HOME in the node configuration as /usr/java/jdk1.8.0_351 but build still used Java 11.

I SSH to the remote node and tried these commands.
export JAVA_HOME=“path to Java 1.8”
export PATH=$JAVA_HOME/bin:$PATH

I also tried setting in Global tool config JAVA_HOME as /usr/java/jdk1.8.0_351.
No luck. What’s wrong here?

changing something in your shell won’t change anything inside of jenkins.

As I said, goto the configuration page of your agent, and update the environmental variables

You probably want to set both JAVA_HOME and PATH so they are setup right to point to the right directories

You’ve given us nothing about what isn’t working, what you are trying todo, so i’m not sure why you are expecting us to be able to provide any different information.

1 Like

I tried setting JAVA_HOME but it gets overridden by some Jenkins default
Setting JAVA_HOME_TEST appears on the agent, so setting env for agent definitely works