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

Calling super to CPS-transformed methods fails with CpsCallableInvocation

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • workflow-cps-plugin
    • Jenkins 2.72, Pipeline-Groovy Plugin 2.38, Pipeline Shared Groovy Libraries Plugin 2.8 and everything related also latest versions
    • Pipeline - April 2018

      From comment for JENKINS-42563:

      Only super calls to native methods were tested IIRC. Support for super calls to CPS-transformed methods is another matter entirely. Probably a subject for a separate bug report.

      From original issue JENKINS-42563 (please find below a more recent update comment and a smaller reproducer without need of a shared library):

      My goal was to create some abstractions in shared (global pipeline) library so that in the Jenkinsfile I only have the configuration of the build, whereas the re-usable build script logic is fully in the library; so very much like the Section https://jenkins.io/doc/book/pipeline/shared-libraries/#defining-a-more-structured-dsl.

      In the shared library I use simple class inheritance, but the call to a super method fails with CpsCallableInvocation.

      This is the stacktrace:

      hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
          at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:100)
          at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.superCall(DefaultInvoker.java:29)
          at com.acme.B1.build(file:/var/lib/jenkins/jobs/Pipeline-Using-Shared-Library/builds/187/libs/******-shared-library/src/com/acme/B1.groovy:21)
          at acme.b1(/var/lib/jenkins/jobs/Pipeline-Using-Shared-Library/builds/187/libs/******-shared-library/vars/acme.groovy:9)
          at WorkflowScript.run(WorkflowScript:18)
          at ___cps.transform___(Native Method)
          at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:54)
          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.GeneratedMethodAccessor273.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.ClosureBlock.eval(ClosureBlock.java:46)
          at com.cloudbees.groovy.cps.Next.step(Next.java:74)
          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:165)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
          at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
          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:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
      Caused by: hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
          at sun.reflect.GeneratedConstructorAccessor549.newInstance(Unknown Source)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
          at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
          at com.acme.B1.build(B1.groovy)
          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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
          at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1218)
          at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.superCall(DefaultInvoker.java:29)
          ... 29 more

      This is the build console output, before the aforementioned problem:

      [Pipeline] echo
      Pipeline Script using shared library
      [Pipeline] echo
      from Jenkinsfile via "acme.b0"
      [Pipeline] echo
      from C1.build: name from Jenkinsfile via "acme.c1"
      [Pipeline] End of Pipeline
      // And then would be the aforementioned stacktrace output
      

      And at long last, this is the code:

      Jenkinsfile
      #!/usr/bin/env groovy
      
      echo 'Pipeline Script using shared library'
      
      @Library('******-shared-library@branches/*************') _
      
      acme.b0 {
        echo 'from Jenkinsfile via "acme.b0"'
      }
      
      acme.c1 {
        name = 'name from Jenkinsfile via "acme.c1"'
      }
      
      // This does not work:
      acme.b1 {
        name = 'name from Jenkinsfile via "acme.b1"'
      }
      
      vars/acme.groovy
      #!/usr/bin/env groovy
      
      void b0(Closure body) {
        def b0 = new com.acme.B0()
        b0.build(body)
      }
      
      void b1(Closure configBody) {
        def b1 = new com.acme.B1(this)
        b1.build(configBody)
      }
      
      void c1(Closure configBody) {
        def c1 = new com.acme.C1(this)
        c1.build(configBody)
      }
      
      src/com/acme/B0.groovy
      #!/usr/bin/env groovy
      
      package com.acme
      
      class B0 implements Serializable {
      
        public void build(Closure body) {
          body()
        }
      
      }
      
      src/com/acme/B1.groovy
      #!/usr/bin/env groovy
      
      package com.acme
      
      class B1 extends B0 {
      
        def script
      
        B1(def script) {
          this.script = script
        }
      
        public void build(Closure configBody) {
          // First evaluate the body configuration block, and collect configuration into the object:
          def config = [:]
          configBody.resolveStrategy = Closure.DELEGATE_FIRST
          configBody.delegate = config
          configBody()
      
          // Then build, based on the configuration provided:
          super.build() { // !!! This is line #21 where the problem occurs
            script.echo "from B1.build: ${config.name}"
          }
        }
      
      }
      
      src/com/acme/C1.groovy
      #!/usr/bin/env groovy
      
      package com.acme
      
      class C1 implements Serializable {
      
        def script
        def acme
      
        C1(def script) {
          this.script = script
          this.acme = script.acme
        }
      
        public void build(Closure configBody) {
          // First evaluate the body configuration block, and collect configuration into the object:
          def config = [:]
          configBody.resolveStrategy = Closure.DELEGATE_FIRST
          configBody.delegate = config
          configBody()
      
          // Then build, based on the configuration provided:
          acme.b0 {
            script.echo "from C1.build: ${config.name}"
          }
        }
      
      }
      

      Please mind: In this case the approach via acme.c1 and com.acme.C1 calling acme.b0 step is the workaround for the problem...

      Based on the minimal pipeline script example of pmilliken in JENKINS-42563 it still fails:

      • Installed pipeline plugin versions:
        pipeline-model-api: 1.1.9
        pipeline-build-step: 2.5.1
        pipeline-model-definition: 1.1.9
        pipeline-milestone-step: 1.3.1
        pipeline-model-declarative-agent: 1.1.1
        pipeline-stage-step: 2.2
        pipeline-model-extensions: 1.1.9
        script-security: 1.30
        workflow-aggregator: 2.5
        workflow-api: 2.20
        workflow-job: 2.14
        workflow-support: 2.14
        workflow-step-api: 2.12
        workflow-basic-steps: 2.6
        workflow-cps-global-lib: 2.8
        workflow-cps: 2.38
        blueocean: 1.1.5
        blueocean-pipeline-api-impl: 1.1.5
        
      • Pipeline code:
        class A {
          def script2
          A(script) { script2 = script }
          def test(script) {
            script.echo "In A"
          }
          def testWithoutArgs() {
            script2.echo "In A without args"
          }
        }
        
        class B extends A {
          B(script) { super(script) }
          def test(script) {
            script.echo "In B"
            super.test(script)
          }
          def testWithoutArgs() {
            script2.echo "In B without args"
            super.testWithoutArgs()
          }
        }
        
        node {
        
          stage('A without args') {
            new A(this).testWithoutArgs()
          }
        
          stage('A') {
            new A(this).test(this)
          }
        
          stage('B without args') {
            new B(this).testWithoutArgs()
          }
          
          stage('B') {
            new B(this).test(this)
          }
        
        }
        
      • Build log with disabled sandbox option:
        [Pipeline] node
        Running on master in /var/lib/jenkins/workspace/Sandbox/JENKINS-42563
        [Pipeline] {
        [Pipeline] stage
        [Pipeline] { (A without args)
        [Pipeline] echo
        In A without args
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] stage
        [Pipeline] { (A)
        [Pipeline] echo
        In A
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] stage
        [Pipeline] { (B without args)
        [Pipeline] echo
        In B without args
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] }
        [Pipeline] // node
        [Pipeline] End of Pipeline
        hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
        	at sun.reflect.GeneratedConstructorAccessor143.newInstance(Unknown Source)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
        	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
        	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
        	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:110)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
        	at A.testWithoutArgs(WorkflowScript)
        	at B.super$2$testWithoutArgs(WorkflowScript)
        	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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.superCall(DefaultInvoker.java:29)
        Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
        	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:100)
        	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.superCall(DefaultInvoker.java:29)
        	at B.testWithoutArgs(WorkflowScript:20)
        	at WorkflowScript.run(WorkflowScript:35)
        	at ___cps.transform___(Native Method)
        	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:54)
        	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
        	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:77)
        	at sun.reflect.GeneratedMethodAccessor190.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:83)
        	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173)
        	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
        	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:162)
        	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
        	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)
        Finished: FAILURE
        
      • Log with enabled sandbox option:
        [Pipeline] node
        Running on master in /var/lib/jenkins/workspace/Sandbox/JENKINS-42563
        [Pipeline] {
        [Pipeline] stage
        [Pipeline] { (A without args)
        [Pipeline] echo
        In A without args
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] stage
        [Pipeline] { (A)
        [Pipeline] echo
        In A
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] stage
        [Pipeline] { (B without args)
        [Pipeline] echo
        In B without args
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] }
        [Pipeline] // node
        [Pipeline] End of Pipeline
        hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
        	at sun.reflect.GeneratedConstructorAccessor143.newInstance(Unknown Source)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
        	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
        	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
        	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:110)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
        	at A.testWithoutArgs(WorkflowScript)
        	at B.super$2$testWithoutArgs(WorkflowScript)
        	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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:207)
        	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onSuperCall(GroovyInterceptor.java:49)
        	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onSuperCall(SandboxInterceptor.java:380)
        	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:204)
        	at org.kohsuke.groovy.sandbox.impl.Checker.checkedSuperCall(Checker.java:210)
        	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.superCall(SandboxInvoker.java:24)
        Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
        	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:100)
        	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
        	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:207)
        	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onSuperCall(GroovyInterceptor.java:49)
        	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onSuperCall(SandboxInterceptor.java:380)
        	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:204)
        	at org.kohsuke.groovy.sandbox.impl.Checker.checkedSuperCall(Checker.java:210)
        	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.superCall(SandboxInvoker.java:24)
        	at B.testWithoutArgs(WorkflowScript:20)
        	at WorkflowScript.run(WorkflowScript:35)
        	at ___cps.transform___(Native Method)
        	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:54)
        	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
        	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:77)
        	at sun.reflect.GeneratedMethodAccessor190.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:83)
        	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173)
        	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
        	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:162)
        	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:330)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
        	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
        	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)
        Finished: FAILURE
        

          [JENKINS-45982] Calling super to CPS-transformed methods fails with CpsCallableInvocation

          Bernardo Vale added a comment -

          Do you guys have updates regarding this issue?

           

          I'm trying to do the same thing and ran into this problem =/

          Bernardo Vale added a comment - Do you guys have updates regarding this issue?   I'm trying to do the same thing and ran into this problem =/

          Seems like you can not call methods from other classes from the constructor, this example also fails.

          public class ClassForNothing{ 
           public void doNothing(){} 
          } 
          
          public class MyClass implements Serializable{ 
           public MyClass(){ 
            def t = new ClassForNothing() 
            t.doNothing() 
           } 
          } 
          
          def test = new MyClass()

          Ivan Fernandez Calvo added a comment - Seems like you can not call methods from other classes from the constructor, this example also fails. public class ClassForNothing{ public void doNothing(){} } public class MyClass implements Serializable{ public MyClass(){ def t = new ClassForNothing() t.doNothing() } } def test = new MyClass()

          Jesse Glick added a comment -

          Correct, that is illegal, unless doNothing is marked @NonCPS. As designed.

          Jesse Glick added a comment - Correct, that is illegal, unless doNothing is marked @NonCPS . As designed.

          Andrew Bayer added a comment -

          Hoorah, figured it out. PR updated accordingly.

          Andrew Bayer added a comment - Hoorah, figured it out. PR updated accordingly.

          Erez Arbell added a comment - - edited

          I do not understand from the above comment what is the status of this issue. Can you explain?

          I am also facing the same issue. Here is a simple example:

          class A {
            def speak(script) {
              script.echo "Hello from A"
            }
          }
          
          class B extends A {
            def speak(script) {
              script.echo "Hello from B"
              super.speak(script)
            }
          }
          
          node('master') {
            def b = new B()
            b.speak(this)
          }
          

          Output:

          [Pipeline] {
          [Pipeline] echo
          Hello from B
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
          Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
          	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:100)
          	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
          	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
          	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:214)
          	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onSuperCall(GroovyInterceptor.java:49)
          	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onSuperCall(SandboxInterceptor.java:390)
          	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:211)
          	at org.kohsuke.groovy.sandbox.impl.Checker.checkedSuperCall(Checker.java:217)
          	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.superCall(SandboxInvoker.java:25)
          	at B.speak(WorkflowScript:10)
          	at WorkflowScript.run(WorkflowScript:16)
          	at ___cps.transform___(Native Method)
          	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:54)
          	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.GeneratedMethodAccessor71.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.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
          	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
          	at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
          	at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
          	at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
          	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)
          Finished: FAILURE
          

          A workaround is:

          class B extends A {
            @NonCPS
            def speak(script) {
          ...

          then output is 

          [Pipeline] {
          [Pipeline] echo
          Hello from B
          [Pipeline] echo
          Hello from A
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          

          but this is not ideal solution because then I can't call other CPS methods from this nonCPS method.

          Erez Arbell added a comment - - edited I do not understand from the above comment what is the status of this issue. Can you explain? I am also facing the same issue. Here is a simple example: class A { def speak(script) { script.echo "Hello from A" } } class B extends A { def speak(script) { script.echo "Hello from B" super .speak(script) } } node( 'master' ) { def b = new B() b.speak( this ) } Output: [Pipeline] { [Pipeline] echo Hello from B [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:100) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:214) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onSuperCall(GroovyInterceptor.java:49) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onSuperCall(SandboxInterceptor.java:390) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:211) at org.kohsuke.groovy.sandbox.impl.Checker.checkedSuperCall(Checker.java:217) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.superCall(SandboxInvoker.java:25) at B.speak(WorkflowScript:10) at WorkflowScript.run(WorkflowScript:16) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:54) 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.GeneratedMethodAccessor71.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.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28) at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55) at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16) 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) Finished: FAILURE A workaround is: class B extends A { @NonCPS def speak(script) { ... then output is  [Pipeline] { [Pipeline] echo Hello from B [Pipeline] echo Hello from A [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS but this is not ideal solution because then I can't call other CPS methods from this nonCPS method.

          Andrew Bayer added a comment -

          This has been merged and will probably be in the next workflow-cps release, 2.46.

          Andrew Bayer added a comment - This has been merged and will probably be in the next workflow-cps release, 2.46.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pom.xml
          http://jenkins-ci.org/commit/script-security-plugin/5b4ff55c2bae0de436e4bc9b5960eb7a4455ad0f
          Log:
          Merge pull request #190 from abayer/groovy-sandbox-1.17

          JENKINS-45982 Switch to groovy-sandbox 1.17 release.

          Compare: https://github.com/jenkinsci/script-security-plugin/compare/8e4eac03fd71...5b4ff55c2bae

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml http://jenkins-ci.org/commit/script-security-plugin/5b4ff55c2bae0de436e4bc9b5960eb7a4455ad0f Log: Merge pull request #190 from abayer/groovy-sandbox-1.17 JENKINS-45982 Switch to groovy-sandbox 1.17 release. Compare: https://github.com/jenkinsci/script-security-plugin/compare/8e4eac03fd71...5b4ff55c2bae

          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/672122274d4eab2217ae4d5460c984f953905d63
          Log:
          JENKINS-45982 Fix calling CPS-transformed super methods.

          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/672122274d4eab2217ae4d5460c984f953905d63 Log: JENKINS-45982 Fix calling CPS-transformed super methods.

          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/7ac0d46ce3ef04525a74570962328a12adea9add
          Log:
          Merge pull request #212 from abayer/jenkins-45982

          JENKINS-45982 Fix calling CPS-transformed super methods.

          Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/a63e6848d642...7ac0d46ce3ef

          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/7ac0d46ce3ef04525a74570962328a12adea9add Log: Merge pull request #212 from abayer/jenkins-45982 JENKINS-45982 Fix calling CPS-transformed super methods. Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/a63e6848d642...7ac0d46ce3ef

          Mor L added a comment -

          Hi,

          when is workflow-cps  2.46 going to be released?

          As it stands all my inheritance trials in Shared Libraries ended in failures due to this and similar errors.

          Thanks.

          Mor L added a comment - Hi, when is workflow-cps   2.46 going to be released? As it stands all my inheritance trials in Shared Libraries ended in failures due to this and similar errors. Thanks.

            abayer Andrew Bayer
            reinholdfuereder Reinhold Füreder
            Votes:
            9 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated:
              Resolved: