Jenkins setup:
Version 2.464
I’ve created a custom jenkins docker image and when I build it, I add openjdk8 so my old jobs can work.
In my dockerfile:
FROM jenkins/inbound-agent:latest-alpine3.20-jdk17
RUN apk add openjdk8
When I build and exec into the container on my local build machine:
/home/jenkins # java -version
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode)
/home/jenkins # /usr/lib/jvm/java-1.8-openjdk/bin/java -version
openjdk version "1.8.0_402"
OpenJDK Runtime Environment (IcedTea 3.30.0) (Alpine 8.402.06-r0)
OpenJDK 64-Bit Server VM (build 25.402-b06, mixed mode)
When I call that image from my pod template in a simple script:
podTemplate {
node('jdk8') {
stage('Run shell') {
sh 'cd /usr/lib/jvm/java-1.8-openjdk/bin/ && ./java -version'
sh 'sleep 1000'
}
}
}
+ cd /usr/lib/jvm/java-1.8-openjdk/bin/
+ ./java -version
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode)
So…WHY? How would that happen? Why isn’t that behaving the same as the docker run?
I know I can use pod templates and use dedicated containers to run the job with the container command, but the jobs I’m transferring from an old jenkins version only have GUI build params, not groovy, so i need to accomodate these folks. I thought I could simply use the jnlp
container name trick and it works, but for some reason, it isn’t recongizing JDK8, only version 17.