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

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during class generation: Method code too large! error in pipeline Script

    XMLWordPrintable

Details

    Description

      Note from the Maintainers

      There is partial fix for this for Declarative pipelines in pipeline-model-definition-plugin v1.4.0 and later, significantly improved in v1.8.4.  Due to the extent to which it change how pipelines are executed it is turned off by default.  It can be turned on by setting a JVM property (either on the command-line or in Jenkins script console):

      org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true 

      As noted, this still works best with a Jenkinsfile with pipeline directive as the only root item in the file.
      Since v1.8.2 this workaround reports an informative error for pipelines using `def` variables before the pipeline directive. Add a @Field annotation to those declaration.
      This workaround generally does NOT work if the pipeline directive inside a shared library method. If this is a scenario you want, please come join the pipeline authoring SIG and we can discuss.

      Please give it a try and provide feedback. 

      Hi,

      We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

      Can you please suggest a quick workaround. It's a blocker for us.

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      General error during class generation: Method code too large!
      
      java.lang.RuntimeException: Method code too large!
      	at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
      	at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
      	at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
      	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)
      
      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
      

      Attachments

        1. errorIncomaptiblewithlocalvar.txt
          8 kB
        2. java.png
          java.png
          294 kB
        3. JenkinsCodeTooLarge.groovy
          45 kB
        4. Script_Splitting.groovy
          44 kB
        5. Script_Splittingx10.groovy
          519 kB

        Issue Links

          Activity

            anudeeplalam Anudeep Lalam created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Epic Link JENKINS-35390 [ 171183 ]
            jglick Jesse Glick made changes -
            Component/s workflow-cps-plugin [ 21713 ]
            Component/s pipeline [ 21692 ]
            Assignee Jesse Glick [ jglick ]
            jglick Jesse Glick made changes -
            Priority Blocker [ 1 ] Major [ 3 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-50033 [ JENKINS-50033 ]
            ruudp Ruud P made changes -
            Comment [ I brake up the code but it did not help, so what i am doing wrong here? Anny solution available?

             

            oringinal:

            stages \{
             stage('Test') \{
             parallel \{
                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                 ..... more as 200

             

            change it into:

            stages \{
               stage('Test') \{ maintest()}

            (in the same file i defined a function maintest with all the parallel stages)

            def maintest()

            parallel \{

               stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                stage(bla1t') \{
                  when \{expression bla}}
                    steps \{node(label: 'bla') \{test('bla', '')}}}

                 ..... more as 200

             

              ]
            eplodn1 efo plo made changes -
            Attachment JenkinsCodeTooLarge.groovy [ 46318 ]
            wim Wim Gaethofs made changes -
            Link This issue is related to JENKINS-56500 [ JENKINS-56500 ]
            siva_baisani sivanarayana baisani made changes -
            Priority Major [ 3 ] Blocker [ 1 ]
            bitwiseman Liam Newman made changes -
            Remote Link This issue links to "PR-355 (Web Link)" [ 23835 ]
            bitwiseman Liam Newman made changes -
            Comment [ This PR should mitigate this issue for most scenarios.  Splits the declarative code into classes and methods. ]
            moglimcgrath M McGrath made changes -
            Rank Ranked higher
            bitwiseman Liam Newman made changes -
            Attachment Script_Splitting.groovy [ 49805 ]
            bitwiseman Liam Newman made changes -
            Attachment Script_Splittingx10.groovy [ 49806 ]
            ifernandezcalvo Ivan Fernandez Calvo made changes -
            Link This issue is related to JENKINS-61389 [ JENKINS-61389 ]
            henryborchers Henry Borchers made changes -
            Comment [ [~bitwiseman] I tried it in an jenkinsfile-runner dockerfile and it actually worked. I only tried it on a single Jenkinsfile that was giving me the Method code too large error and it started to to run. ]
            bitwiseman Liam Newman made changes -
            Link This issue is related to JENKINS-61389 [ JENKINS-61389 ]
            jenkinsneveragain Paweł made changes -
            Attachment errorIncomaptiblewithlocalvar.txt [ 53893 ]
            bitwiseman Liam Newman made changes -
            Description Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}

            {panel:title=My title}
            Note from the Maintainers:

            Please try the latest release with script
            https://github.com/jenkinsci/pipeline-model-definition-plugin/releases/tag/pipeline-model-definition-1.8.2

            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            bitwiseman Liam Newman made changes -
            Description
            {panel:title=My title}
            Note from the Maintainers:

            Please try the latest release with script
            https://github.com/jenkinsci/pipeline-model-definition-plugin/releases/tag/pipeline-model-definition-1.8.2

            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            {panel:title=Note from the Maintainers}
            There is partial fix for this for Declarative pipelines in pipeline-model-definition-plugin v1.4.0 and later, significantly improved in v1.8.2.  Due to the extent to which it change how pipelines are executed it is turned off by default.  It can be turned on by setting a JVM property (either on the command-line or in Jenkins script console):

            {{org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true }}

            As noted, this still works best with a Jenkinsfile with {{pipeline}} directive as the only root item in the file.
            Since v1.8.2 this workaround reports an informative error for pipelines using `def` variables before the {{pipeline}} directive. Add a {{@Field}} annotation to those declaration.
            This workaround generally does NOT work if the {{pipeline}} directive inside a shared library method. If this is a scenario you want, please come join the pipeline authoring SIG and we can discuss.

            Please give it a try and provide feedback.  
            Please try the latest release with script
            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            bitwiseman Liam Newman made changes -
            Description {panel:title=Note from the Maintainers}
            There is partial fix for this for Declarative pipelines in pipeline-model-definition-plugin v1.4.0 and later, significantly improved in v1.8.2.  Due to the extent to which it change how pipelines are executed it is turned off by default.  It can be turned on by setting a JVM property (either on the command-line or in Jenkins script console):

            {{org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true }}

            As noted, this still works best with a Jenkinsfile with {{pipeline}} directive as the only root item in the file.
            Since v1.8.2 this workaround reports an informative error for pipelines using `def` variables before the {{pipeline}} directive. Add a {{@Field}} annotation to those declaration.
            This workaround generally does NOT work if the {{pipeline}} directive inside a shared library method. If this is a scenario you want, please come join the pipeline authoring SIG and we can discuss.

            Please give it a try and provide feedback.  
            Please try the latest release with script
            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            {panel:title=Note from the Maintainers}
            There is partial fix for this for Declarative pipelines in pipeline-model-definition-plugin v1.4.0 and later, significantly improved in v1.8.2.  Due to the extent to which it change how pipelines are executed it is turned off by default.  It can be turned on by setting a JVM property (either on the command-line or in Jenkins script console):

            {{org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true }}

            As noted, this still works best with a Jenkinsfile with {{pipeline}} directive as the only root item in the file.
            Since v1.8.2 this workaround reports an informative error for pipelines using `def` variables before the {{pipeline}} directive. Add a {{@Field}} annotation to those declaration.
            This workaround generally does NOT work if the {{pipeline}} directive inside a shared library method. If this is a scenario you want, please come join the pipeline authoring SIG and we can discuss.

            Please give it a try and provide feedback. 
            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            moskovych Oleh Moskovych made changes -
            Link This issue is related to JENKINS-64846 [ JENKINS-64846 ]
            bitwiseman Liam Newman made changes -
            Description {panel:title=Note from the Maintainers}
            There is partial fix for this for Declarative pipelines in pipeline-model-definition-plugin v1.4.0 and later, significantly improved in v1.8.2.  Due to the extent to which it change how pipelines are executed it is turned off by default.  It can be turned on by setting a JVM property (either on the command-line or in Jenkins script console):

            {{org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true }}

            As noted, this still works best with a Jenkinsfile with {{pipeline}} directive as the only root item in the file.
            Since v1.8.2 this workaround reports an informative error for pipelines using `def` variables before the {{pipeline}} directive. Add a {{@Field}} annotation to those declaration.
            This workaround generally does NOT work if the {{pipeline}} directive inside a shared library method. If this is a scenario you want, please come join the pipeline authoring SIG and we can discuss.

            Please give it a try and provide feedback. 
            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            {panel:title=Note from the Maintainers}
            There is partial fix for this for Declarative pipelines in pipeline-model-definition-plugin v1.4.0 and later, significantly improved in v1.8.4.  Due to the extent to which it change how pipelines are executed it is turned off by default.  It can be turned on by setting a JVM property (either on the command-line or in Jenkins script console):

            {{org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true }}

            As noted, this still works best with a Jenkinsfile with {{pipeline}} directive as the only root item in the file.
            Since v1.8.2 this workaround reports an informative error for pipelines using `def` variables before the {{pipeline}} directive. Add a {{@Field}} annotation to those declaration.
            This workaround generally does NOT work if the {{pipeline}} directive inside a shared library method. If this is a scenario you want, please come join the pipeline authoring SIG and we can discuss.

            Please give it a try and provide feedback. 
            {panel}


            Hi,

            We are getting below error in Pipeline which has some 495 lines of groovy code. Initially we assumed that one of our methods has an issue but once we remove any 30-40 lines of Pipeline groovy, this issue is not coming.

            Can you please suggest a quick workaround. It's a blocker for us.

            {code}
            org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
            General error during class generation: Method code too large!

            java.lang.RuntimeException: Method code too large!
            at groovyjarjarasm.asm.MethodWriter.a(Unknown Source)
            at groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source)
            at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:815)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
            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)

            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
            {code}
            sodul Stephane Odul made changes -
            Attachment java.png [ 54946 ]

            People

              Unassigned Unassigned
              anudeeplalam Anudeep Lalam
              Votes:
              80 Vote for this issue
              Watchers:
              95 Start watching this issue

              Dates

                Created:
                Updated: