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

Single parameter steps don't work when using named parameter in workflow-cps 2.14/2.15

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • workflow-cps-plugin
    • None
    • workflow-cps 2.14 and 2.15

      Reported over at https://issues.jenkins-ci.org/browse/JENKINS-38037?focusedCommentId=269757&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-269757 - this code:

      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."
          }
      }
      

      ...produces this 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
      

          [JENKINS-38169] Single parameter steps don't work when using named parameter in workflow-cps 2.14/2.15

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - Tentative PR up at https://github.com/jenkinsci/workflow-cps-plugin/pull/56 .

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/main/java/org/jenkinsci/plugins/workflow/cps/DSL.java
          src/test/java/org/jenkinsci/plugins/workflow/DSLTest.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/90f348ece9220c55885d67bb00aeee3737bbeda4
          Log:
          [FIXED JENKINS-38169] Treat single required+named param differently.

          If you call `echo message:'foo'` previous to this change, the Map that
          gets passed as the first element of args ends up being used as the
          sole parameter itself, so you end up with `name:[name:'foo']` being
          passed as the args. That's obviously wrong. So let's add a check to
          see if there is a `soleArgumentKey`, the arg map only has one
          key/value, and that key is equal to `soleArgumentKey` - if that's
          true, just pass the arg map directly.

          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 src/test/java/org/jenkinsci/plugins/workflow/DSLTest.java http://jenkins-ci.org/commit/workflow-cps-plugin/90f348ece9220c55885d67bb00aeee3737bbeda4 Log: [FIXED JENKINS-38169] Treat single required+named param differently. If you call `echo message:'foo'` previous to this change, the Map that gets passed as the first element of args ends up being used as the sole parameter itself, so you end up with `name: [name:'foo'] ` being passed as the args. That's obviously wrong. So let's add a check to see if there is a `soleArgumentKey`, the arg map only has one key/value, and that key is equal to `soleArgumentKey` - if that's true, just pass the arg map directly.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          http://jenkins-ci.org/commit/docker-workflow-plugin/0e95a7bf7af6d647ed3ebc5d1a6ab8dce5c59549
          Log:
          Actually needed to upgrade a bit further to pick up the fix of JENKINS-38169.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml http://jenkins-ci.org/commit/docker-workflow-plugin/0e95a7bf7af6d647ed3ebc5d1a6ab8dce5c59549 Log: Actually needed to upgrade a bit further to pick up the fix of JENKINS-38169 .

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

              Created:
              Updated:
              Resolved: