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

Script works inline but not as extenal .groovy file

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: groovy-plugin
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.60.2
      Ubuntu 16.04
      Groovy Version: 2.4.12 JVM: 1.8.0_144 Vendor: Oracle Corporation OS: Linux
    • Similar Issues:

      Description

      Hi, I have recenlty upgraded my groovy plugin from 1.3 to 2.0 and my external script files suddenly stopped working. I have done a bit of investigating and it seems to be an issue with them being run as external files as apposed to inline. The symptoms are easily reproduced by simple running the groovy below (taken from the jenkins help). Firstly inline which works and then inside an external file which doesnt. the exception details are below the scripts.

       
      import hudson.model.*
       
      // get current thread / Executor
      def thr = Thread.currentThread()
      // get current build
      def build = thr?.executable
       
       
      // get parameters
      def parameters = build?.actions.find{ it }}{{instanceof ParametersAction }?.parameters
      parameters.each {
         println }}{{"parameter ${it.name}:"
         println it.dump()
         println }}{{"-" * }}{{80
      }
       
       
      13:14:35 FATAL: No such property: it for class: groovy.lang.Binding*13:14:35* groovy.lang.MissingPropertyException: No such property: it for class: groovy.lang.Binding*13:14:35* at groovy.lang.Binding.getVariable(Binding.java:63)13:14:35 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:232)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:282)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:286)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:262)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker$checkedGetProperty$0.callStatic(Unknown Source)13:14:35 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)13:14:35 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)13:14:35 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:230)13:14:35 at Script1$_run_closure1.doCall(Script1.groovy:9)13:14:35 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)13:14:35 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)13:14:35 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)13:14:35 at java.lang.reflect.Method.invoke(Method.java:498)13:14:35 at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)13:14:35 at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)13:14:35 at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)13:14:35 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)13:14:35 at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)13:14:35 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)13:14:35 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)13:14:35 at org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker.invoke(BooleanReturningMethodInvoker.java:51)13:14:35 at org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper.call(BooleanClosureWrapper.java:53)13:14:35 at org.codehaus.groovy.runtime.DefaultGroovyMethods.find(DefaultGroovyMethods.java:3884)13:14:35 at org.codehaus.groovy.runtime.dgm$193.invoke(Unknown Source)13:14:35 at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)13:14:35 at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)13:14:35 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)13:14:35 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)13:14:35 at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)13:14:35 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:100)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:153)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:157)13:14:35 at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)13:14:35 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)13:14:35 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)13:14:35 at Script1.run(Script1.groovy:9)13:14:35 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:141)13:14:35 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:165)13:14:35 at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)13:14:35 at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)13:14:35 at org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper.preCheckout(PreSCMBuildStepsWrapper.java:127)13:14:35 at jenkins.scm.SCMCheckoutStrategy.preCheckout(SCMCheckoutStrategy.java:76)13:14:35 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:484)13:14:35 at hudson.model.Run.execute(Run.java:1735)13:14:35 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:542)13:14:35 at hudson.model.ResourceController.execute(ResourceController.java:97)13:14:35 at hudson.model.Executor.run(Executor.java:405)

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              pmbsa Paul Broughton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: