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

Single parameter metasteps don't work with named-parameter symbols as of workflow-cps 2.14

      Syntax that previously worked, like archiveArtifacts(allowEmptyArchive:true, artifacts: 'foo') (against a 2.x core that has the archiveArtifacts symbol), no longer works as of workflow-cps 2.14. I'm seeing stacktraces like:

      java.lang.IllegalArgumentException: Failed to prepare multiShape step
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:313)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:129)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
      	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      	at WorkflowScript.run(WorkflowScript:1)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang.String
      	at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:177)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:121)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:372)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
      	at org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable.instantiate(UninstantiatedDescribable.java:175)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:364)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
      	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:195)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:311)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:129)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
      	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
      	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      	... 30 more
      

      I've reproduced this in DSLTest.metaStepSyntax on this branch.

          [JENKINS-38037] Single parameter metasteps don't work with named-parameter symbols as of workflow-cps 2.14

          Andrew Bayer added a comment -

          Worth mentioning that earlier testing pointed to this commit of mine as the culprit.

          Andrew Bayer added a comment - Worth mentioning that earlier testing pointed to this commit of mine as the culprit.

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Figured it out - sigh. PR up at https://github.com/jenkinsci/workflow-cps-plugin/pull/53 .

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/a06779a2b831adc8042fa76be7f1f2747a8cb91b
          Log:
          [FIXED JENKINS-38037] Single-arg check for executable symbols fix

          Use the DescribableModel for symbols related to a meta-step when
          determining whether they should be parsed as having a single required
          argument.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java http://jenkins-ci.org/commit/workflow-cps-plugin/a06779a2b831adc8042fa76be7f1f2747a8cb91b Log: [FIXED JENKINS-38037] Single-arg check for executable symbols fix Use the DescribableModel for symbols related to a meta-step when determining whether they should be parsed as having a single required argument.

          Chris Sawczuk added a comment - - edited

          It appears this is still not fixed for all cases. Using the unstash DSL method will cause crashes with the exact same stacktrace using workflow-cps 2.15:

          stage("Create file")
          {
              node {
                  sh 'touch myfile'
                  stash name:"stash-name", includes:'myfile'
              }
          }
          
          stage("Crash by executing single argument DSL function")
          {
              node {
                  unstash name:"stash-name"
                  println "We'll never get here."
              }
          }
          

          Results in the following stacktrace:

          org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang.String
          	at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:247)
          	at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:121)
          	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:372)
          	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)
          	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257)
          	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:195)
          	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181)
          	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
          	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120)
          	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
          	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
          	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
          	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
          	at WorkflowScript.run(WorkflowScript:12)
          	at ___cps.transform___(Native Method)
          	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
          	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
          	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
          	at sun.reflect.GeneratedMethodAccessor509.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
          	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
          	at sun.reflect.GeneratedMethodAccessor558.invoke(Unknown Source)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          	at java.lang.reflect.Method.invoke(Method.java:498)
          	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
          	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
          	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
          	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
          	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
          	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
          	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
          	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          	at java.lang.Thread.run(Thread.java:745)
          Finished: FAILURE
          

          Apologies if this is not the correct place to add comments.

          Chris Sawczuk added a comment - - edited It appears this is still not fixed for all cases. Using the unstash DSL method will cause crashes with the exact same stacktrace using workflow-cps 2.15: stage( "Create file" ) { node { sh 'touch myfile' stash name: "stash-name" , includes: 'myfile' } } stage( "Crash by executing single argument DSL function" ) { node { unstash name: "stash-name" println "We'll never get here." } } Results in the following stacktrace: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang. String at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:247) at org.jenkinsci.plugins.structs.describable.DescribableModel.<init>(DescribableModel.java:121) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:372) at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:257) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:195) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:120) at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16) at WorkflowScript.run(WorkflowScript:12) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.GeneratedMethodAccessor509.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55) at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45) at sun.reflect.GeneratedMethodAccessor558.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:58) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang. Thread .run( Thread .java:745) Finished: FAILURE Apologies if this is not the correct place to add comments.

          Andrew Bayer added a comment -

          Reproduced - grr. I'll try to fix this today. Sorry.

          Andrew Bayer added a comment - Reproduced - grr. I'll try to fix this today. Sorry.

          Andrew Bayer added a comment -

          Also, for what it's worth, unstash 'foo' still works - it's just when you pass a named parameter that it barfs. I'll fix it, but there is definitely a workaround for now.

          Andrew Bayer added a comment - Also, for what it's worth, unstash 'foo' still works - it's just when you pass a named parameter that it barfs. I'll fix it, but there is definitely a workaround for now.

          Andrew Bayer added a comment -

          Opened JENKINS-38169 for this, since it's a similar but different issue.

          Andrew Bayer added a comment - Opened JENKINS-38169 for this, since it's a similar but different issue.

          Andrew Bayer added a comment -

          czuckie - JENKINS-38169 has been merged and released as workflow-cps 2.17 - sorry about that!

          Andrew Bayer added a comment - czuckie - JENKINS-38169 has been merged and released as workflow-cps 2.17 - sorry about that!

            abayer Andrew Bayer
            abayer Andrew Bayer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: