-
Bug
-
Resolution: Not A Defect
-
Minor
-
Jenkins Remoting : remoting-3206.vb_15dcf73f6a_9
Jenkins Controller: 2.426.3 LTS
JDK installed in Jenkins Controller : Amazon Corretto JDK 17
Build Agent Image : Alpine 3.19.1
Background:
We run AMAZON ECS Fargate based agents in combination with remoting jars. Basically a customized inbound agent image.
Recently we were trying to upgrade Jenkins Controller and Build agents to Java 17. Since we have several (1000+) projects which still use Java 8, we decided to add a copy of JDK 17 in agent image and keep Java 8 as the installed version
Java 8 is installed with apk add openjdk8
Java 17 zip [Temurin] is downloaded and extracted to /opt/jre17/ which the remoting agent uses.
Issue:
When using Java 17 in Alpine OS with Remoting agent, it fails to recognize the installed Java 8 version.
That is if we run a test job, we will get below output:
+ java -version openjdk version "17.0.10" 2024-01-16 LTS OpenJDK Runtime Environment Corretto-17.0.10.7.1 (build 17.0.10+7-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.10.7.1 (build 17.0.10+7-LTS, mixed mode, sharing) + which java /usr/lib/jvm/java-1.8-openjdk/bin/java
That is, even when java binary is pointing to Java 8, we are still getting version as 17.
But if we set Java 11 version for the Remoting Agent, this works as expected, see below
+ java -version openjdk version "1.8.0_392" OpenJDK Runtime Environment (IcedTea 3.29.0) (Alpine 8.392.08-r1) OpenJDK 64-Bit Server VM (build 25.392-b08, mixed mode) + which java /usr/lib/jvm/java-8-openjdk/bin/java
This issue is not coming, when the base image is Ubuntu 22.
Steps to Replicate:
Start a local container instance of Alpine
sudo docker run -it alpine:latest /bin/sh
Install wget, curl, tar, xz, openjdk8
apk update && apk add tar xz openjdk8 wget curl
Verify Java verison
java -version javac -version
Download & Extract Latest Temurin JRE 17 to a seperate folder (lets say /opt/jre17)
mkdir /opt/jre17
wget -q -O - "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.10%2B7/OpenJDK17U-jre_x64_alpine-linux_hotspot_17.0.10_7.tar.gz" | tar -xz --strip=1 -C /opt/jre17
Download latest remoting JAR (As of today) and save it to a folder, lets say /agent
(either from your Jenkins Instance or latest version from Remoting Artifactory Repo)
mkdir /agent
curl -sO https://<JenkinsURL>/jnlpJars/agent.jar
Create a Jenkins Permanent agent in Controller & configure the agent with Websocket
Start the newly configured agent
/opt/jre17/bin/java agent.jar <rest of the secret and workdir configuration>
Run a test job with newly configured agent, run java -version
Repeat the same with JRE 11
mkdir /opt/jre11
wget -q -O - "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.21%2B9/OpenJDK11U-jre_x64_alpine-linux_hotspot_11.0.21_9.tar.gz" | tar -xz --strip=1 -C /opt/jre11
/opt/jre11/bin/java agent.jar <rest of the secret and workdir configuration>
Run a test job with newly configured agent, run java -version