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

Unable to use ParametersAction using the list constructor when run in sandbox

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • script-security-plugin
    • None
    • Jenkins 2.73, Script Security Plugin 1.31

      ParametersAction can't be constructed using the list constructor.  Works with varargs.

      import hudson.model.*;
      def pv1 = new StringParameterValue("Param1", "Value1");
      def pv2 = new StringParameterValue("Param2", "Value2");
      def pa1 = new ParametersAction(pv1,pv2);
      
      def pl = new ArrayList<ParameterValue>();
      pl.add(pv1);
      pl.add(pv2);
      def pa2 = new ParametersAction(pl);

      Error

      java.lang.IllegalArgumentException: array element type mismatch
      	at java.lang.reflect.Array.set(Native Method)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.parametersForVarargs(GroovyCallSiteSelector.java:104)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.matches(GroovyCallSiteSelector.java:51)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovyCallSiteSelector.constructor(GroovyCallSiteSelector.java:166)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:132)
      	at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:195)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:200)
      	at org.kohsuke.groovy.sandbox.impl.Checker$checkedConstructor.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:9)

      Whilst we can work around this by switching to the varargs constructor, it's a symptom of a bigger problem.  We have the same issue with attempting to use scheduleBuild2 and passing a cause and action.  For this, there is no workaround.

            Unassigned Unassigned
            pwiseman Peter Wiseman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: