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

groovy plugin sets GROOVY_HOME wrong when the path differs on the slaves from the master

    Details

    • Similar Issues:

      Description

      I have a Linux master on which a Groovy installation is defined, let's say on /home/jenkins/groovy. Some of my slaves are Windows on which that same Groovy installation is overriden to for example c:\tools\groovy.

      The way the groovy plugin code works (https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/Groovy.java line 86) is it asks the master for a Groovy installation and if it exists sets the GROOVY_HOME env var from that installation. It should ask the slave for the correct directory.

      In the buildCommandLine() method the correct way to find the Groovy installation is used (forNode) but that is only used to find the executable and not to set the GROOVY_HOME var.

      The wrong GROOVY_HOME results in
      Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/tools/GroovyStarter
      Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.tools.GroovyStarter
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

      IMHO setting the GROOVY_HOME var is not necessary, the groovy bat or sh file does this correctly (see also http://6by9.wordpress.com/2011/01/31/why-you-should-never-set-groovy_home/). Even when setting GROOVY_HOME like it is now, it is done wrong.

        Attachments

          Activity

          mr_dfuse Nico Mommaerts created issue -
          mr_dfuse Nico Mommaerts made changes -
          Field Original Value New Value
          Description I have a Linux master on which a Groovy installation is defined, let's say on /home/jenkins/groovy. Some of my slaves are Windows on which that same Groovy installation is overriden to for example c:\tools\groovy.

          The way the groovy plugin code works (https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/Groovy.java line 86) is it asks the master for a Groovy installation and if it exists sets the GROOVY_HOME env var from that installation. It should ask the slave for the correct directory.

          In the buildCommandLine() method the correct way to find the Groovy installation is used (forNode) but that is only used to find the executable and not to set the GROOVY_HOME var.

          IMHO setting the GROOVY_HOME var is not necessary, the groovy bat or sh file does this correctly (see also http://6by9.wordpress.com/2011/01/31/why-you-should-never-set-groovy_home/). Even when setting GROOVY_HOME like it is now, it is done wrong.
          I have a Linux master on which a Groovy installation is defined, let's say on /home/jenkins/groovy. Some of my slaves are Windows on which that same Groovy installation is overriden to for example c:\tools\groovy.

          The way the groovy plugin code works (https://github.com/jenkinsci/groovy-plugin/blob/master/src/main/java/hudson/plugins/groovy/Groovy.java line 86) is it asks the master for a Groovy installation and if it exists sets the GROOVY_HOME env var from that installation. It should ask the slave for the correct directory.

          In the buildCommandLine() method the correct way to find the Groovy installation is used (forNode) but that is only used to find the executable and not to set the GROOVY_HOME var.

          The wrong GROOVY_HOME results in
          Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/tools/GroovyStarter
          Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.tools.GroovyStarter
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

          IMHO setting the GROOVY_HOME var is not necessary, the groovy bat or sh file does this correctly (see also http://6by9.wordpress.com/2011/01/31/why-you-should-never-set-groovy_home/). Even when setting GROOVY_HOME like it is now, it is done wrong.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Vojtech Juranek
          Path:
          src/main/java/hudson/plugins/groovy/Groovy.java
          http://jenkins-ci.org/commit/groovy-plugin/d36abd1f2d481b5a4c474a8625eda61becf6c438
          Log:
          [FIXED JENKINS-25275] Set up correct GROOVY_HOME env. variable

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Vojtech Juranek Path: src/main/java/hudson/plugins/groovy/Groovy.java http://jenkins-ci.org/commit/groovy-plugin/d36abd1f2d481b5a4c474a8625eda61becf6c438 Log: [FIXED JENKINS-25275] Set up correct GROOVY_HOME env. variable
          scm_issue_link SCM/JIRA link daemon made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          mr_dfuse Nico Mommaerts added a comment -

          thanks for fixing this so fast! was gonna look at it myself this weekend but you beat me to it

          Show
          mr_dfuse Nico Mommaerts added a comment - thanks for fixing this so fast! was gonna look at it myself this weekend but you beat me to it
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 159189 ] JNJira + In-Review [ 196013 ]

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              mr_dfuse Nico Mommaerts
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: