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

Plugin creates groovy command line with classpath in wrong position

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Component/s: groovy-plugin
    • Labels:
    • Environment:
      jenkins 1.620
      groovy-plugin 1.25
    • Similar Issues:

      Description

      When using the groovy plugin and providing both classpath and properties settings the plugin produces a command line with the arguments in incorrect order. The classpath is not put as the first argument. I also noticed the order of the arguments is shuffled compared to how entered.

      Reverted to groovy-plugin 1.14 (previously used and known to be working) and correct behaviour was restored. We haven't tried to test intermediate versions to try and identify the exact version the behaviour changed in.

      In the source changes for the plugin I saw a change for JENKINS-27964 made in version 1.25 that modified the code that is responsible for building the command. Not sure if this is relevant or significant.

        Attachments

          Activity

          Hide
          vjuranek vjuranek added a comment -

          Hi,
          what kind of issues is caused by providing properties before classpath? AFAIK the order of parameters shouldn't matter.
          Thanks

          Show
          vjuranek vjuranek added a comment - Hi, what kind of issues is caused by providing properties before classpath? AFAIK the order of parameters shouldn't matter. Thanks
          Hide
          grmcnair Gordon McNair added a comment -

          Here's some sample output to show how the behaviour changes.

          First run with classpath first, gets exception below because I didn't set up full build environment but successfully compiled ...

          [ec2-user@ip-172-31-180-17 functional_test_ji_5.5_cclas]$ /opt/groovy/groovy-2.1.6/bin/groovy -cp lib/*:build -Dfoo=bah /ventyx/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy
          Caught: java.lang.ExceptionInInitializerError
          java.lang.ExceptionInInitializerError

          Now run with properties set before classpath, getting compile errors as groovy isn't finding the library jars ...

          [ec2-user@ip-172-31-180-17 functional_test_ji_5.5_cclas]$ /opt/groovy/groovy-2.1.6/bin/groovy -Dfoo=bah -cp lib/*:build /ventyx/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy
          org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 1: unable to resolve class wslite.rest.RESTClient
          @ line 1, column 1.
          import wslite.rest.RESTClient
          ^

          /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 3: unable to resolve class com.abb.ventyx.cclas.common.config.Config
          @ line 3, column 1.
          import static com.abb.ventyx.cclas.common.config.Config.config
          ^

          /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 4: unable to resolve class org.apache.commons.lang.StringUtils
          @ line 4, column 1.
          import static org.apache.commons.lang.StringUtils.remove
          ^

          /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 5: unable to resolve class org.apache.commons.lang.StringUtils
          @ line 5, column 1.
          import static org.apache.commons.lang.StringUtils.substringBefore
          ^

          4 errors

          Show
          grmcnair Gordon McNair added a comment - Here's some sample output to show how the behaviour changes. First run with classpath first, gets exception below because I didn't set up full build environment but successfully compiled ... [ec2-user@ip-172-31-180-17 functional_test_ji_5.5_cclas] $ /opt/groovy/groovy-2.1.6/bin/groovy -cp lib/*:build -Dfoo=bah /ventyx/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy Caught: java.lang.ExceptionInInitializerError java.lang.ExceptionInInitializerError Now run with properties set before classpath, getting compile errors as groovy isn't finding the library jars ... [ec2-user@ip-172-31-180-17 functional_test_ji_5.5_cclas] $ /opt/groovy/groovy-2.1.6/bin/groovy -Dfoo=bah -cp lib/*:build /ventyx/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 1: unable to resolve class wslite.rest.RESTClient @ line 1, column 1. import wslite.rest.RESTClient ^ /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 3: unable to resolve class com.abb.ventyx.cclas.common.config.Config @ line 3, column 1. import static com.abb.ventyx.cclas.common.config.Config.config ^ /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 4: unable to resolve class org.apache.commons.lang.StringUtils @ line 4, column 1. import static org.apache.commons.lang.StringUtils.remove ^ /media/ephemeral0/jenkins/light/workspace/functional_test_ji_5.5_cclas/etc/echo_cclas_version.groovy: 5: unable to resolve class org.apache.commons.lang.StringUtils @ line 5, column 1. import static org.apache.commons.lang.StringUtils.substringBefore ^ 4 errors
          Hide
          vjuranek vjuranek added a comment -

          thanks, obviously I was wrong and Groovy requires for some reason classpath to be the first argument... will look on it

          Show
          vjuranek vjuranek added a comment - thanks, obviously I was wrong and Groovy requires for some reason classpath to be the first argument... will look on it
          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
          src/test/java/hudson/plugins/groovy/ClassPathTest.java
          http://jenkins-ci.org/commit/groovy-plugin/031b83fb8ca7cde1ee70e5cbaf3d1f14aa3e580b
          Log:
          [FIXED JENKINS-29577] Ensure classpath is the first option

          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 src/test/java/hudson/plugins/groovy/ClassPathTest.java http://jenkins-ci.org/commit/groovy-plugin/031b83fb8ca7cde1ee70e5cbaf3d1f14aa3e580b Log: [FIXED JENKINS-29577] Ensure classpath is the first option
          Hide
          grmcnair Gordon McNair added a comment -

          Thanks for looking at it and sorting it out!

          Cheers,
          Gordon.

          Show
          grmcnair Gordon McNair added a comment - Thanks for looking at it and sorting it out! Cheers, Gordon.

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              grmcnair Gordon McNair
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: