I have a Jenkins agent named jenkins-agent2
connected with Jenkins controller. The agent is based on this imagejenkins/ssh-agent:alpine-jdk17
The default Java installed on the Jenkins agent is
openjdk version "17.0.8.1" 2023-08-24
OpenJDK Runtime Environment Temurin-17.0.8.1+1 (build 17.0.8.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (build 17.0.8.1+1, mixed mode)
However, I am installing jdk-17.0.10
with the shell script below
In summary, it downloads the tar.gz file extracts it at a location sets JAVA_HOME, and adds JAVA_HOME/bin to the PATH
Similarly, I install Maven 3.9.6
Then I run the pipeline to check if the tools are installed correctly, for which the code is below:
pipeline{
agent {
label 'jenkins-agent2'
}
tools {
jdk 'jdk-17.10.0'
maven 'maven-3.9.6'
}
stages {
stage ("Java installation") {
steps {
sh '''
whoami
echo $JAVA_HOME
echo $MAVEN_HOME
echo $PATH
which java
java -version
mvn -version
'''
}
}
stage("Docker installation") {
steps {
sh '''
docker version
docker run hello-world
'''
}
}
}
}
But it is not picking up the correct Java which should be 17.10.0 and mvn -version
complains about the JAVA_HOME
Any help would be great about why it is not picking up the correct JAVA (17.10.0) installation and why the maven installation is not working. Many thanks in advance