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

MultipleCompilationErrorsException: You are not allowed to override the final method __cps__2() from class …

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Pipeline Shared Groovy Libraries Plugin 2.2+

      When importing an internal library (as described at https://github.com/jenkinsci/workflow-cps-global-lib-plugin), I'm encountering an issue:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: 
      WorkflowScript: -1: You are not allowed to override the final method ___cps___2() from class 'com.acme.foo.test.MyTest'. 
      @ line -1, column -1. 
      1 error 
      at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) 
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073) 
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591) 
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) 
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) 
      at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) 
      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) 
      at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) 
      at groovy.lang.GroovyShell.parse(GroovyShell.java:700) 
      at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:67) 
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:410) 
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:373) 
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:213) 
      at hudson.model.ResourceController.execute(ResourceController.java:98) 
      at hudson.model.Executor.run(Executor.java:410) 
      Finished: FAILURE
      

      Using the following libraries to produce this error:

      workflowLibs/src/com/acme/foo/test/MyTest.groovy:

      #!groovy 
      package com.acme.foo.test 
      class MyTest 
      { 
      def mytest1() {} 
      } 
      

      workflowLibs/src/com/acme/foo/test/MyOtherTest.groovy:

      #!groovy 
      package com.acme.foo.test 
      class MyOtherTest { 
      def test1() {} 
      def test2() {} 
      }
      

      Pipeline content:

      #!groovy 
      import com.acme.foo.test.MyTest 
      import com.acme.foo.test.MyOtherTest 
      
      class MyTestExtended 
      extends MyTest 
      { 
      def mytestfunction() {} 
      } 
      
      node('localhost') { 
      def pipeline = new MyTestExtended() 
      }
      

      Now here's the odd part. The error only manifests for certain class names. The error is thrown with the stack trace described above when the class/file is named "MyTest", "Test2", "Test3", or "What". If I change the name to "Test1" or "DoStuff", the same pipeline finishes successfully.

      Additionally, the second (unused) import in the pipeline script, is required to produce the issue. When I remove the second import statement (import com.acme.foo.test.MyOtherTest), the pipeline passes for all names of the primary class being expanded upon.

            jglick Jesse Glick
            dtranter Dan Tranter
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: