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

Allow to use @Grab in a Script Console

    XMLWordPrintable

Details

    Description

      Currently @Grab works only in Groovy scripts run on a forked JVM. In a Script Console and System Groovy Scripts it ends with:

      FATAL: org/apache/ivy/core/report/ResolveReport
      java.lang.NoClassDefFoundError: org/apache/ivy/core/report/ResolveReport
      

      It is sometimes useful to be able to extend script abilities with external libs (like HTTP Builder).

      Attachments

        Issue Links

          Activity

            Code changed in jenkins
            User: Kohsuke Kawaguchi
            Path:
            changelog.html
            pom.xml
            http://jenkins-ci.org/commit/jenkins/2ad427f6c3d187c5b330151b85e1a578e340cf2a
            Log:
            [FIXED JENKINS-18349 JENKINS-18405]

            Integrated the fix toward 1.521.

            Compare: https://github.com/jenkinsci/jenkins/compare/0b8917b34479...2ad427f6c3d1

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: changelog.html pom.xml http://jenkins-ci.org/commit/jenkins/2ad427f6c3d187c5b330151b85e1a578e340cf2a Log: [FIXED JENKINS-18349 JENKINS-18405] Integrated the fix toward 1.521. Compare: https://github.com/jenkinsci/jenkins/compare/0b8917b34479...2ad427f6c3d1

            I'm not seeing any fix for @Grab Grape support in the github links from the previous comment.
            The same issue was fixed in job-dsl-plugin, see https://issues.jenkins-ci.org/browse/JENKINS-16361
            There's also a document about embedding groovy here http://groovy.codehaus.org/Embedding+Groovy

            It would be great if groovy grape support is added to Jenkins.

            savornicesei Simona Avornicesei added a comment - I'm not seeing any fix for @Grab Grape support in the github links from the previous comment. The same issue was fixed in job-dsl-plugin, see https://issues.jenkins-ci.org/browse/JENKINS-16361 There's also a document about embedding groovy here http://groovy.codehaus.org/Embedding+Groovy It would be great if groovy grape support is added to Jenkins.
            danielbeck Daniel Beck added a comment -

            Not a bug.

            danielbeck Daniel Beck added a comment - Not a bug.
            danielbeck Daniel Beck added a comment -

            Is this about the Groovy plugin (Groovy and system Groovy build steps), or core (Script Console in /manage and for each slave)?

            danielbeck Daniel Beck added a comment - Is this about the Groovy plugin (Groovy and system Groovy build steps), or core (Script Console in /manage and for each slave)?

            This is about the Script Console and pretty much every place but the Groovy Plug-in and Groovy build step. Perhaps most importantly moving forward, this issue impacts scripts run by the Workflow plug-in.

            kbaltrinic Kenneth Baltrinic added a comment - This is about the Script Console and pretty much every place but the Groovy Plug-in and Groovy build step. Perhaps most importantly moving forward, this issue impacts scripts run by the Workflow plug-in.
            danielbeck Daniel Beck added a comment -

            kbaltrinic: To clarify, the 'Groovy script' build step is not affected (unsurprising, as it's a straightforward groovy invocation), but the 'system Groovy script' build step in Groovy plugin is?

            Regarding scope, did you contact the reporter or is that your interpretation of this report? (Note that not too long ago, component names did not have the '-plugin' suffix making it difficult to tell in some cases whether a report is about the "something" related features in Jenkins, or the "something plugin".)

            I'm asking because I'd like to split this into one issue per component. This way (IMO) the issues have a change to actually get implemented by the respective plugins'/core maintainers.

            danielbeck Daniel Beck added a comment - kbaltrinic : To clarify, the 'Groovy script' build step is not affected (unsurprising, as it's a straightforward groovy invocation), but the 'system Groovy script' build step in Groovy plugin is? Regarding scope, did you contact the reporter or is that your interpretation of this report? (Note that not too long ago, component names did not have the '-plugin' suffix making it difficult to tell in some cases whether a report is about the "something" related features in Jenkins, or the "something plugin".) I'm asking because I'd like to split this into one issue per component. This way (IMO) the issues have a change to actually get implemented by the respective plugins'/core maintainers.
            kbaltrinic Kenneth Baltrinic added a comment - - edited

            Perhaps I don't understand the terms clearly either so I will attempt to be a descriptive as possible. First this is with Jenkins v 1.592 which has the Hudson Groovy Builder 1.24 installed and all of the Workflow 1.0 plugins installed. In its earlier version Hudson Groovy Builder appears to have also been called the "Groovy Plugin."

            With this combination of components, @Grab works when using the "Execute Groovy script" option within a free-style job (this is what I meant above the "Groovy Plugin" and "Groovy build step".) To my knowledge this is the only place that it works.

            The locations I specifically have tried and confirmed not to work are:

            1. In the Groovy Console: Jenkins > Manage Jenkins > Script Console
            2. In workflow jobs, in the Workflow Definition when using Groovy CPS DSL.
            3. A coworker of mine on a slightly older build (1.552) also reports that he gets the same error when attempting to use @Grab with the Build Flow Plugin (v 0.10).

            I have not contacted the reporter but am presuming this to be the same issue because I am getting the same error in what I presumed to be the same location (i.e. I interpret his reference to the "Groovy Script console" to be the same location as I referenced in #1 above.) I am not clear on what his original reference to "System Groovy Scripts" refers to but it seems to yet a forth location where @grab does not work.

            As to whether or not this is a single issue with a common root cause and solution or multiple issues that will each need their own resolution, I will defer to more knowledgable heads. However there already are several other tickets open about adding @Grab support to various plugins, etc: JENKINS-15512, JENKINS-16361, JENKINS-18400, JENKINS-18484. We just seem to be missing one for the new workflow plugin.

            I hope this helps.

            kbaltrinic Kenneth Baltrinic added a comment - - edited Perhaps I don't understand the terms clearly either so I will attempt to be a descriptive as possible. First this is with Jenkins v 1.592 which has the Hudson Groovy Builder 1.24 installed and all of the Workflow 1.0 plugins installed. In its earlier version Hudson Groovy Builder appears to have also been called the "Groovy Plugin." With this combination of components, @Grab works when using the "Execute Groovy script" option within a free-style job (this is what I meant above the "Groovy Plugin" and "Groovy build step".) To my knowledge this is the only place that it works. The locations I specifically have tried and confirmed not to work are: In the Groovy Console: Jenkins > Manage Jenkins > Script Console In workflow jobs, in the Workflow Definition when using Groovy CPS DSL. A coworker of mine on a slightly older build (1.552) also reports that he gets the same error when attempting to use @Grab with the Build Flow Plugin (v 0.10). I have not contacted the reporter but am presuming this to be the same issue because I am getting the same error in what I presumed to be the same location (i.e. I interpret his reference to the "Groovy Script console" to be the same location as I referenced in #1 above.) I am not clear on what his original reference to "System Groovy Scripts" refers to but it seems to yet a forth location where @grab does not work. As to whether or not this is a single issue with a common root cause and solution or multiple issues that will each need their own resolution, I will defer to more knowledgable heads. However there already are several other tickets open about adding @Grab support to various plugins, etc: JENKINS-15512 , JENKINS-16361 , JENKINS-18400 , JENKINS-18484 . We just seem to be missing one for the new workflow plugin. I hope this helps.

            I have added a separate ticket for the workflow plugin: JENKINS-26192

            kbaltrinic Kenneth Baltrinic added a comment - I have added a separate ticket for the workflow plugin: JENKINS-26192
            jglick Jesse Glick added a comment -

            Would be wiser to do JENKINS-29068 first.

            jglick Jesse Glick added a comment - Would be wiser to do JENKINS-29068 first.
            jglick Jesse Glick added a comment -

            Not a long-term solution, but I found a way in JENKINS-26192 to make it work in Pipeline global libraries which as a side effect makes it work throughout Jenkins (unless I go to special effort to suppress that).

            jglick Jesse Glick added a comment - Not a long-term solution, but I found a way in JENKINS-26192 to make it work in Pipeline global libraries which as a side effect makes it work throughout Jenkins (unless I go to special effort to suppress that).
            jglick Jesse Glick added a comment -

            The issue here is that while Groovy bundles the Grape system, you need to have Ivy in the classpath for it to actually work. workflow-cps-global-lib bundles Ivy for this reasons, so other components could make use of Grape if they follow that class loader (or UberClassLoader). In JENKINS-26635 I had to add an optional dependency to the groovy plugin.

            jglick Jesse Glick added a comment - The issue here is that while Groovy bundles the Grape system, you need to have Ivy in the classpath for it to actually work. workflow-cps-global-lib bundles Ivy for this reasons, so other components could make use of Grape if they follow that class loader (or UberClassLoader ). In JENKINS-26635 I had to add an optional dependency to the groovy plugin.

            People

              vjuranek vjuranek
              emszpak Marcin ZajÄ…czkowski
              Votes:
              12 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

                Created:
                Updated: