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

Offer a new Unarchive installer which takes Java archive structure into account

      Jenkins installation
      Installed from docker image jenkinsci/docker - README.me

      Plugins
      Pipeline Maven Plugin

      Configuration - configureTools

      1. JDK :
      2. Maven :
        • name : Default
        • install automatically : true (Install from Apache)
        • version : 3.6.0

      Jenkinsfile
       

      pipeline {
          agent any
      
          stages {
              stage('Clean') {
                  steps {
                      withMaven(maven: 'Default',jdk: 'Java 10') {
                          sh "echo JAVA_HOME=$JAVA_HOME"
                          sh "mvn clean"
                      }
                  }
              }
          }
      }
      

      Error

      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline]\{ (Clean)
      [Pipeline] withMaven
      [withMaven] Options: []
      [withMaven] Available options:
      [withMaven] using JDK installation Java 10
      [withMaven] using Maven installation 'Default' [Pipeline] {
      [Pipeline] sh
      + echo 'JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10'
      JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10
      [Pipeline] sh
      + mvn clean -B -V
      ----- withMaven Wrapper script -----
      The JAVA_HOME environment variable is not defined correctly
      This environment variable is needed to run this program
      NB: JAVA_HOME should point to a JDK not a JRE
      [Pipeline] }
      

      Actual
      JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10

      Expected
      JAVA_HOME=/var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2

      Looks like the automatic set JEVA_HOME is missing the last part of the path

          [JENKINS-54959] Offer a new Unarchive installer which takes Java archive structure into account

          Devin Nusbaum added a comment -

          Yes, this could be useful in some cases, but I do not anticipate having any time to work on this plugin, although if you open a PR to add the feature, I will be happy to review it.

          Devin Nusbaum added a comment - Yes, this could be useful in some cases, but I do not anticipate having any time to work on this plugin, although if you open a PR to add the feature, I will be happy to review it.

          Daniel Beck added a comment -

          Weird, I thought the unzip installers removed a top level directory if there's only one.

          Daniel Beck added a comment - Weird, I thought the unzip installers removed a top level directory if there's only one.

          Daniel Beck added a comment -

          Daniel Beck added a comment - There's an additional option to extract a subdir. https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/hudson/tools/ZipExtractionInstaller/help-subdir.html

          Optional subdirectory of the downloaded and unpacked archive to use as the tool's home directory

          isn't the opposite that we want ? no subdirectory ?

          Benoit Le Gall added a comment - Optional subdirectory of the downloaded and unpacked archive to use as the tool's home directory isn't the opposite that we want ? no subdirectory ?

          Daniel Beck added a comment -

          That's exactly what this does, see the help.

          Daniel Beck added a comment - That's exactly what this does, see the help.

          ha ! I've finally understood ! I first understood that it add a subdirectory to the final path...
          Yes, it's was it does, so now the JAVA_HOME is correctly set.
          But still, I had to open the archive to know what the inner directory was, not very friendly use
          ...

          so now, I just have the following error :

          /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Default/bin/mvn: exec: line 199: /var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2/bin/java: not found

          event if the java file is present
          I will update the SO question with all this.

          Thanks a lot

          Benoit Le Gall added a comment - ha ! I've finally understood ! I first understood that it add a subdirectory to the final path... Yes, it's was it does, so now the JAVA_HOME is correctly set. But still, I had to open the archive to know what the inner directory was, not very friendly use ... so now, I just have the following error : /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Default/bin/mvn: exec: line 199: /var/jenkins_home/tools/hudson.model.JDK/Java_10/jdk-10.0.2/bin/java: not found event if the java file is present I will update the SO question with all this. Thanks a lot

          Daniel Beck added a comment -

          Not executable? Or on a volume marked noexec?

          Daniel Beck added a comment - Not executable? Or on a volume marked noexec?

          Daniel Beck added a comment -

          Reducing priority due to workaround/alternative present.

          Daniel Beck added a comment - Reducing priority due to workaround/alternative present.

          Benoit Le Gall added a comment - - edited

          as it is a automatic installed jdk, it's on the java_home volume for the container. There is no specifics rights/permissions set as I have installed following the documentation.
          Here is what I have

          root@vps536376:~# docker volume inspect jenkins_home
          [
              {
                  "CreatedAt": "2018-12-05T15:41:37+01:00",
                  "Driver": "local",
                  "Labels": null,
                  "Mountpoint": "/var/lib/docker/volumes/jenkins_home/_data",
                  "Name": "jenkins_home",
                  "Options": null,
                  "Scope": "local"
              }
          ]
          root@vps536376:~# ls -l /var/lib/docker/volumes/jenkins_home/_data/tools/hudson.model.JDK/Java_10/jdk-10.0.2/bin/
          total 592
          -rwxr-xr-x 1 root ubuntu   9920 Jun 28 02:54 appletviewer
          -rwxr-xr-x 1 root ubuntu   9864 Jun 28 02:54 idlj
          -rwxr-xr-x 1 root ubuntu  11112 Jun 28 02:54 jaotc
          -rwxr-xr-x 1 root ubuntu   9864 Jun 28 02:54 jar
          -rwxr-xr-x 1 root ubuntu   9872 Jun 28 02:54 jarsigner
          -rwxr-xr-x 1 root ubuntu   9056 Jun 28 02:54 java
          ...
          

          Benoit Le Gall added a comment - - edited as it is a automatic installed jdk, it's on the java_home volume for the container. There is no specifics rights/permissions set as I have installed following the documentation. Here is what I have root@vps536376:~ # docker volume inspect jenkins_home [ { "CreatedAt" : "2018-12-05T15:41:37+01:00" , "Driver" : " local " , "Labels" : null, "Mountpoint" : "/var/lib/docker/volumes/jenkins_home/_data" , "Name" : "jenkins_home" , "Options" : null, "Scope" : " local " } ] root@vps536376:~ # ls -l /var/lib/docker/volumes/jenkins_home/_data/tools/hudson.model.JDK/Java_10/jdk-10.0.2/bin/ total 592 -rwxr-xr-x 1 root ubuntu 9920 Jun 28 02:54 appletviewer -rwxr-xr-x 1 root ubuntu 9864 Jun 28 02:54 idlj -rwxr-xr-x 1 root ubuntu 11112 Jun 28 02:54 jaotc -rwxr-xr-x 1 root ubuntu 9864 Jun 28 02:54 jar -rwxr-xr-x 1 root ubuntu 9872 Jun 28 02:54 jarsigner -rwxr-xr-x 1 root ubuntu 9056 Jun 28 02:54 java ...

          Petr H added a comment - - edited
          • automatically installed JDK (when it worked):
            hudson.model.JDK/JDK8u152/bin/
          • manually downloaded and locally used binary archive (jdk-8u212-linux-x64.tar.gz in this example):
            hudson.model.JDK/JDK8/jdk1.8.0_212/bin/

          Although I can set the Subdirectory of extracted archive to "jdk1.8.0_212" (for the above example) which sets the java home correctly, I'd like to get the same result as with the automatically installed JDK - e.g. without that additional subdirectory in the filesystem path.

          Petr H added a comment - - edited automatically installed JDK (when it worked): hudson.model.JDK/JDK8u152/bin/ manually downloaded and locally used binary archive (jdk-8u212-linux-x64.tar.gz in this example): hudson.model.JDK/JDK8/ jdk1.8.0_212 /bin/ Although I can set the Subdirectory of extracted archive to "jdk1.8.0_212" (for the above example) which sets the java home correctly, I'd like to get the same result as with the automatically installed JDK - e.g. without that additional subdirectory in the filesystem path.

            Unassigned Unassigned
            legall_benoit Benoit Le Gall
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: