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

Unable to define new ParametersAction in Groovy script file

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Blocker Blocker
    • script-security-plugin
    • None
    • Jenkins ver. 2.46.1 LTS (all plugins up-to-date as of 04/19/2017)

      Trying to set new ParametersAction in a Groovy script run as "Execute system Groovy script - Groovy script file"

      def pa = new ParametersAction(new StringParameterValue(job_name_BY_variable_name, username))
      

      Yields the following error:

      ERROR: Build step failed with exception
      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new hudson.model.StringParameterValue java.lang.String groovy.util.slurpersupport.NodeChildren
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:126)
      	at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:191)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:188)
      	at org.kohsuke.groovy.sandbox.impl.Checker$checkedConstructor$2.callStatic(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
      	at Script1.run(Script1.groovy:98)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.run(GroovySandbox.java:141)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:165)
      	at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
      	at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      	at hudson.model.Build$BuildExecution.build(Build.java:206)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      	at hudson.model.Run.execute(Run.java:1728)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:405)
      Build step 'Execute system Groovy script' marked build as failure
      

      This works just fine using "Groovy command" and pasting the script into the "Execute system Groovy script" box; however, does not work and throws the above exception when executed as a "Groovy script file".

          [JENKINS-43699] Unable to define new ParametersAction in Groovy script file

          Jesse Glick added a comment -

          Presumably username here is not actually a String. Cannot diagnose without steps to reproduce from scratch.

          Jesse Glick added a comment - Presumably username here is not actually a String . Cannot diagnose without steps to reproduce from scratch.

          Andrew Bayer added a comment -

          Yeah, if you look at the error message, the last type listed is groovy.util.slurpersupport.NodeChildren, so that's username. Fix that to be a String and you should be able to approve that.

          Andrew Bayer added a comment - Yeah, if you look at the error message, the last type listed is groovy.util.slurpersupport.NodeChildren , so that's username . Fix that to be a String and you should be able to approve that.

            Unassigned Unassigned
            shane_rice Shane Rice
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: