Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-75130

JDK tools not work for agent and extract type installation

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • jdk-tool-plugin
    • None
    • 2.479.2

      Problem

      When jdk tool is installed with option Extract*.zip/*.tar.gz from github, the java version is not set correctly

      What is expected

      When use jdk tool the java version is according to installation from tool

      Example

      JDK tool is confifgured as image

       

      pipeline {
      
          agent {
              kubernetes {
                  label "myagent"
              }
          }
      
          stages {
              stage("JDK tool bahaviour"){
                 
                  tools {
                     jdk "jdk21"
                  }
                  steps{
                      container("myagent") {
                          script {
                              println "JAVA_HOME is ${env.JAVA_HOME}"
                              sh 'java -version'
                          }
                      }
                  }
              }
         }
      } 

      With this pipeline the java version expected is 21 but returns version 11 that is the java version of the agent

       

       

      Unpacking https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz to /home/jenkins/agent/tools/hudson.model.JDK/jdk21 on myagent-83v0g
      [Pipeline] envVarsForTool
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] container
      [Pipeline] {
      [Pipeline] script
      [Pipeline] {
      [Pipeline] echo
      JAVA_HOME is /home/jenkins/agent/tools/hudson.model.JDK/jdk21
      [Pipeline] sh
      + java -version
      openjdk version "11.0.20" 2023-07-18
      OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04)
      OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed mode, sharing) 

      The JAVA_HOME is set to /home/jenkins/agent/tools/hudson.model.JDK/jdk21 but it's not correct due to there is no /bin folder inside. JAVA_HOME should be set to /agent/tools/hudson.model.JDK/jdk21/jdk-21.0.5+11

      Even if JAVA_HOME with correct /bin path is set into pipeline the JAVA_HOME is set to previous value

      Unpacking https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_x64_linux_hotspot_21.0.5_11.tar.gz to /home/jenkins/agent/tools/hudson.model.JDK/jdk21 on myagent-vfp6q 
      [Pipeline] envVarsForTool 
      [Pipeline] withEnv 
      [Pipeline] { 
      [Pipeline] container 
      [Pipeline] { 
      [Pipeline] script 
      [Pipeline] { 
      [Pipeline] echo JAVA_HOME is /home/jenkins/agent/tools/hudson.model.JDK/jdk21 
      [Pipeline] sh 
      + java -version 
      openjdk version "11.0.20" 2023-07-18 
      OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04) 
      OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed mode, sharing) 
      [Pipeline] echo JAVA_HOME is /home/jenkins/agent/tools/hudson.model.JDK/jdk21 
      [Pipeline] sh 
      + java -version 
      openjdk version "11.0.20" 2023-07-18 
      OpenJDK Runtime Environment (build 11.0.20+8-post-Ubuntu-1ubuntu122.04) 
      OpenJDK 64-Bit Server VM (build 11.0.20+8-post-Ubuntu-1ubuntu122.04, mixed mode, sharing)
      

       

       

          [JENKINS-75130] JDK tools not work for agent and extract type installation

            Unassigned Unassigned
            garramja Javier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: