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

Groovy script can not resolve import classes like hudson.scm.SubversionSCM

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      In my script, I start by import some classes like hudson.scm.SubversionSCM.
      But execution failed with "unable to resolve class hudson.scm.SubversionSCM"

      I use groovy-post-build to create a new tag job after each project release success build and need to instanciate new SubversionSCM to change svn url configuation.

      I may have missed something ?

        Attachments

          Issue Links

            Activity

            Hide
            joantune João Antunes added a comment -

            the same happens with me, is this normal?

            Show
            joantune João Antunes added a comment - the same happens with me, is this normal?
            Hide
            joantune João Antunes added a comment -

            so, running the import on the ssh -p port localhost groovysh i get:

            groovy:000> import hudson.scm.SubversionSCM
            groovy:000> ERROR java.lang.IncompatibleClassChangeError:
            the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 5 but got 4
            at java_lang_Runnable$run.call (Unknown Source)
            at hudson.cli.GroovyshCommand.main (GroovyshCommand.java:70)
            at org.jenkinsci.main.modules.sshd.CLICommandAdapter$1.run (CLICommandAdapter.java:34)
            at org.jenkinsci.main.modules.sshd.AsynchronousCommand$1.run (AsynchronousCommand.java:104)

            Show
            joantune João Antunes added a comment - so, running the import on the ssh -p port localhost groovysh i get: groovy:000> import hudson.scm.SubversionSCM groovy:000> ERROR java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 5 but got 4 at java_lang_Runnable$run.call (Unknown Source) at hudson.cli.GroovyshCommand.main (GroovyshCommand.java:70) at org.jenkinsci.main.modules.sshd.CLICommandAdapter$1.run (CLICommandAdapter.java:34) at org.jenkinsci.main.modules.sshd.AsynchronousCommand$1.run (AsynchronousCommand.java:104)
            Hide
            joantune João Antunes added a comment -

            actually, this also happens when I do just a purge:


            fenix-ashes:~/JenkinsSVNScripts# ssh -p 1414 jenkins@localhost groovysh
            Groovy Shell (1.8.5, JVM: 1.6.0_22)
            Type 'help' or '\h' for help.
            -------------------------------------------------------------------------------
            groovy:000> purge
            groovy:000> ERROR java.lang.IncompatibleClassChangeError:
            the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 5 but got 4
            at java_lang_Runnable$run.call (Unknown Source)
            at hudson.cli.GroovyshCommand.main (GroovyshCommand.java:70)
            at org.jenkinsci.main.modules.sshd.CLICommandAdapter$1.run (CLICommandAdapter.java:34)
            at org.jenkinsci.main.modules.sshd.AsynchronousCommand$1.run (AsynchronousCommand.java:104)

            Show
            joantune João Antunes added a comment - actually, this also happens when I do just a purge: – fenix-ashes:~/JenkinsSVNScripts# ssh -p 1414 jenkins@localhost groovysh Groovy Shell (1.8.5, JVM: 1.6.0_22) Type 'help' or '\h' for help. ------------------------------------------------------------------------------- groovy:000> purge groovy:000> ERROR java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Exception do not match. Expected 5 but got 4 at java_lang_Runnable$run.call (Unknown Source) at hudson.cli.GroovyshCommand.main (GroovyshCommand.java:70) at org.jenkinsci.main.modules.sshd.CLICommandAdapter$1.run (CLICommandAdapter.java:34) at org.jenkinsci.main.modules.sshd.AsynchronousCommand$1.run (AsynchronousCommand.java:104) –
            Hide
            joantune João Antunes added a comment -

            so, according to http://stackoverflow.com/questions/7826967/geb-incompatibleclasschangeerror Java 7 seems to be the issue.. I'm thinking on recompilink jenkins with Java 7

            Show
            joantune João Antunes added a comment - so, according to http://stackoverflow.com/questions/7826967/geb-incompatibleclasschangeerror Java 7 seems to be the issue.. I'm thinking on recompilink jenkins with Java 7
            Hide
            joantune João Antunes added a comment -

            ok, so, I was running jenkins with Java 6, switched to run it with Java 7, and the purge now works, but the import gives me the error:

            groovy:000> import jenkins.scm.SubversionSCM
            ERROR org.codehaus.groovy.tools.shell.CommandException:
            Invalid import definition: 'import jenkins.scm.SubversionSCM'; reason: startup failed:
            script13432436404381481316699.groovy: 1: unable to resolve class jenkins.scm.SubversionSCM
            @ line 1, column 1.
            import jenkins.scm.SubversionSCM
            ^

            1 error

            Show
            joantune João Antunes added a comment - ok, so, I was running jenkins with Java 6, switched to run it with Java 7, and the purge now works, but the import gives me the error: groovy:000> import jenkins.scm.SubversionSCM ERROR org.codehaus.groovy.tools.shell.CommandException: Invalid import definition: 'import jenkins.scm.SubversionSCM'; reason: startup failed: script13432436404381481316699.groovy: 1: unable to resolve class jenkins.scm.SubversionSCM @ line 1, column 1. import jenkins.scm.SubversionSCM ^ 1 error
            Hide
            joantune João Antunes added a comment -

            Apparently, Hudson's community found the error, and corrected it already: http://issues.hudson-ci.org/browse/HUDSON-6068 - trying to do the same in jenkins now

            Show
            joantune João Antunes added a comment - Apparently, Hudson's community found the error, and corrected it already: http://issues.hudson-ci.org/browse/HUDSON-6068 - trying to do the same in jenkins now
            Hide
            joantune João Antunes added a comment -

            Nicolas: We had the same problem, but for differente environments of Groovy, you are using it through the groovy-post-build, I was using it through the SSH CLI groovysh. I solved this for my case, and will make a pull request (basicly you have to change the classloader to use the uberClassLoader. I attained it with the following diff:

            • final ClassLoader cl = Thread.currentThread().getContextClassLoader();
              +final ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader == null ? Thread.currentThread()
              + .getContextClassLoader() : Jenkins.getInstance().getPluginManager().uberClassLoader;

            )
            You just have to do the same to the classloader on the Groovy interpreter in groovy-postbuild. If I find some extra time, I'll try to fix that plugin and make a pull request, but no promises (it should be straightforward though if you have some experience with java and git.

            Show
            joantune João Antunes added a comment - Nicolas: We had the same problem, but for differente environments of Groovy, you are using it through the groovy-post-build, I was using it through the SSH CLI groovysh. I solved this for my case, and will make a pull request (basicly you have to change the classloader to use the uberClassLoader. I attained it with the following diff: final ClassLoader cl = Thread.currentThread().getContextClassLoader(); +final ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader == null ? Thread.currentThread() + .getContextClassLoader() : Jenkins.getInstance().getPluginManager().uberClassLoader; ) You just have to do the same to the classloader on the Groovy interpreter in groovy-postbuild. If I find some extra time, I'll try to fix that plugin and make a pull request, but no promises (it should be straightforward though if you have some experience with java and git.
            Hide
            jglick Jesse Glick added a comment -

            FYI - JENKINS-6068 is the issue in this JIRA instance.

            Show
            jglick Jesse Glick added a comment - FYI - JENKINS-6068 is the issue in this JIRA instance.
            Hide
            joantune João Antunes added a comment - - edited

            so, it means that this issue is resolved, right? so I guess we should close it. My problem was actually a bit different, it was the behaviour/origin, but with the SSH command groovysh, I created a new issue, JENKINS-14982, corrected it on my git repo and made a pull request https://github.com/jenkinsci/jenkins/pull/550

            Show
            joantune João Antunes added a comment - - edited so, it means that this issue is resolved, right? so I guess we should close it. My problem was actually a bit different, it was the behaviour/origin, but with the SSH command groovysh, I created a new issue, JENKINS-14982 , corrected it on my git repo and made a pull request https://github.com/jenkinsci/jenkins/pull/550
            Show
            ikedam ikedam added a comment - https://github.com/jenkinsci/groovy-postbuild-plugin/pull/18
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: ikedam
            Path:
            src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java
            src/test/resources/plugins/dependee.hpi
            http://jenkins-ci.org/commit/groovy-postbuild-plugin/1a77ddbb4d5fe20f05d4b0d7559cc62daa8a52fe
            Log:
            JENKINS-14154 Added a test to demonstrate JENKINS-14154.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: ikedam Path: src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java src/test/resources/plugins/dependee.hpi http://jenkins-ci.org/commit/groovy-postbuild-plugin/1a77ddbb4d5fe20f05d4b0d7559cc62daa8a52fe Log: JENKINS-14154 Added a test to demonstrate JENKINS-14154 .
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: ikedam
            Path:
            src/main/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorder.java
            http://jenkins-ci.org/commit/groovy-postbuild-plugin/fd22c9c5fe345cba0f356441811312509c97a908
            Log:
            [FIXED JENKINS-14154] Allows to access other plugins.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: ikedam Path: src/main/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorder.java http://jenkins-ci.org/commit/groovy-postbuild-plugin/fd22c9c5fe345cba0f356441811312509c97a908 Log: [FIXED JENKINS-14154] Allows to access other plugins.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: ikedam
            Path:
            src/main/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorder.java
            src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java
            src/test/resources/plugins/dependee.hpi
            http://jenkins-ci.org/commit/groovy-postbuild-plugin/dac19b7d590df830a94019871eee1ed6f9322e9c
            Log:
            Merge pull request #18 from ikedam/feature/JENKINS-14154_AccessAllPlugins

            JENKINS-14154 Allow to access to other plugins

            Compare: https://github.com/jenkinsci/groovy-postbuild-plugin/compare/9d4982d1bc70...dac19b7d590d

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: ikedam Path: src/main/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorder.java src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderTest.java src/test/resources/plugins/dependee.hpi http://jenkins-ci.org/commit/groovy-postbuild-plugin/dac19b7d590df830a94019871eee1ed6f9322e9c Log: Merge pull request #18 from ikedam/feature/ JENKINS-14154 _AccessAllPlugins JENKINS-14154 Allow to access to other plugins Compare: https://github.com/jenkinsci/groovy-postbuild-plugin/compare/9d4982d1bc70...dac19b7d590d
            Hide
            ikedam ikedam added a comment -

            Fixed in 2.1.
            It will be available in a day.

            Show
            ikedam ikedam added a comment - Fixed in 2.1. It will be available in a day.

              People

              • Assignee:
                ikedam ikedam
                Reporter:
                ncoquelet Nicolas Coquelet
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: