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

Multiple assignment in pipeline fails with LHS Error

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None
    • Jenkins 2.69
    • workflow-cps 2.46

      Multiple assignment like:

      def (a, b) = [1,2]

       No longer works, I believe this worked in Jenkins around 2.65 (and the pipeline components from around that release)

          [JENKINS-45575] Multiple assignment in pipeline fails with LHS Error

          Andrew Bayer added a comment -

          Throwing this on my queue to see if I can get multiple assignment working without too much work. If it would be a lot of work, I'll probably close as won't fix.

          Andrew Bayer added a comment - Throwing this on my queue to see if I can get multiple assignment working without too much work. If it would be a lot of work, I'll probably close as won't fix.

          Kevin Browder added a comment -

          abayer If you can thanks, it's not a huge deal but having as much parity with non-cps groovy would be great

          jglick I've seen a few more of this type of thing pop up in your issue tracker, would it be helpful to have test-only contributions?   Perhaps things that are known not to work can have negative tests.  The reason I ask is that it appears that groovy/cps types of issues seem to have a relatively high barrier to entry to fix, but a low barrier to demonstrate the issue.

          Kevin Browder added a comment - abayer If you can thanks, it's not a huge deal but having as much parity with non-cps groovy would be great jglick  I've seen a few more of this type of thing pop up in your issue tracker, would it be helpful to have test-only contributions?   Perhaps things that are known not to work can have negative tests.  The reason I ask is that it appears that groovy/cps types of issues seem to have a relatively high barrier to entry to fix, but a low barrier to demonstrate the issue.

          Jesse Glick added a comment -

          PRs adding tests are definitely welcome. Generally you would just prefix it with

          @Issue("JENKINS-45575")
          @Ignore("TODO not yet implemented")

          This way the PR can be merged immediately, and any dev who wishes to work on it has a test-driven development head start: just file a second PR which fixes the behavior and deletes the @Ignore.

          Jesse Glick added a comment - PRs adding tests are definitely welcome. Generally you would just prefix it with @Issue( "JENKINS-45575" ) @Ignore( "TODO not yet implemented" ) This way the PR can be merged immediately, and any dev who wishes to work on it has a test-driven development head start: just file a second PR which fixes the behavior and deletes the @Ignore .

          Denys Digtiar added a comment -

          abayer There is also an issue with a simple instantiation of the `groovy.lang.Tuple`. It seems to be blocked by the Script Security. Details are below. Let me know if this is a separate issue and I will raise a different ticket.

          Jenkins 2.95
          Script Security 1.39

          Test Pipeline

          node {
              def output = stuff()
              echo output[0]
              echo output[1]
          }
          
          def stuff() {
              return new Tuple(1, 'banana')
          }
          
          org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new groovy.lang.Tuple java.lang.Integer java.lang.String
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:144)
          	at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:197)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:202)
          	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.constructorCall(SandboxInvoker.java:21)
          	at WorkflowScript.stuff(WorkflowScript:8)
          	at WorkflowScript.run(WorkflowScript:2)
          	at ___cps.transform___(Native Method)
          	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:96)
          	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:62)
          	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:83)
          	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
          	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
          	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
          	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
          	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
          	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
          	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243)
          	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231)
          	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
          	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:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          

          Denys Digtiar added a comment - abayer There is also an issue with a simple instantiation of the `groovy.lang.Tuple`. It seems to be blocked by the Script Security. Details are below. Let me know if this is a separate issue and I will raise a different ticket. Jenkins 2.95 Script Security 1.39 Test Pipeline node { def output = stuff() echo output[0] echo output[1] } def stuff() { return new Tuple(1, 'banana' ) } org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified new groovy.lang.Tuple java.lang. Integer java.lang. String at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:144) at org.kohsuke.groovy.sandbox.impl.Checker$3.call(Checker.java:197) at org.kohsuke.groovy.sandbox.impl.Checker.checkedConstructor(Checker.java:202) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.constructorCall(SandboxInvoker.java:21) at WorkflowScript.stuff(WorkflowScript:8) at WorkflowScript.run(WorkflowScript:2) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:96) 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:62) 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:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) 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:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748)

          Andrew Bayer added a comment -

          duemir - Sorry for the late response. Yes, that'd be a separate issue specific to script-security.

          Andrew Bayer added a comment - duemir - Sorry for the late response. Yes, that'd be a separate issue specific to script-security .

          Andrew Bayer added a comment -

          So this was my dumb mistake - I added support for multiple assignments...but only in non-sandboxed mode. Oops. Anyway, https://github.com/cloudbees/groovy-cps/pull/81 adds multiple assignment support in sandbox as well.

          Andrew Bayer added a comment - So this was my dumb mistake - I added support for multiple assignments...but only in non-sandboxed mode. Oops. Anyway, https://github.com/cloudbees/groovy-cps/pull/81 adds multiple assignment support in sandbox as well.

          Denys Digtiar added a comment -

          abayer It sound's like I don't need to raise a separate script-security ticket after all. Correct?

          Denys Digtiar added a comment - abayer It sound's like I don't need to raise a separate script-security ticket after all. Correct?

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pom.xml
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/9a82584c267f84a4dce925a69d45ad6018196a0a
          Log:
          [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes

          Specifically https://github.com/cloudbees/groovy-cps/pull/81 and https://github.com/cloudbees/groovy-cps/pull/82

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/9a82584c267f84a4dce925a69d45ad6018196a0a Log: [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes Specifically https://github.com/cloudbees/groovy-cps/pull/81 and https://github.com/cloudbees/groovy-cps/pull/82

          Andrew Bayer added a comment -

          Will be in next release of workflow-cps - 2.46.

          Andrew Bayer added a comment - Will be in next release of workflow-cps - 2.46.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          Jenkinsfile
          pom.xml
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/78b137d8743ea3cf80ae302ec89f8aeabf3eb944
          Log:
          Merge pull request #206 from abayer/jenkins-45575-jenkins-49679

          [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes

          Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/57bda81325d5...78b137d8743e

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: Jenkinsfile pom.xml src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/78b137d8743ea3cf80ae302ec89f8aeabf3eb944 Log: Merge pull request #206 from abayer/jenkins-45575-jenkins-49679 [JENKINS-45575, JENKINS-49679] Test multiple assignment CPS fixes Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/57bda81325d5...78b137d8743e

            abayer Andrew Bayer
            kbrowder Kevin Browder
            Votes:
            7 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: