-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
Jenkins ver. 2.150.2
There is partial fix for this 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.
When working with a declarative pipeline script, we run into an error "Method Code too large".
This seems to happen when the code between 'pipeline{}' is more than a specific size.
I'm creating this issue for this component following the suggestion of Jesse Glick at the issue 37984
I've attached a declarative pipeline script that reproduces the issue.
- is related to
-
JENKINS-37984 org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during class generation: Method code too large! error in pipeline Script
-
- Open
-
OK, I'm reporting back my experience converting a scripted pipeline (900 LoC) into a declarative one (1k LoC).
First, let me just say that I love the neat structure and the whole experience of working with declarative pipelines. The conversion felt like tidying up.
I hit the issue when I added the last two stages.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during class generation: Method too large: WorkflowScript.__cps__9839 ()Lcom/cloudbees/groovy/cps/impl/CpsFunction;
But after adding
org.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true
to my Manage Jenkins > Script Console (just paste the snippet above and click `Run` and then start a new build)
the issue went away.
Just for the sake of completeness, I also had to add the same setting to `javaOpts` in my Jenkins' helm chart (I'm using k8s + JCasC), so I don't have to manually set it in the Script Console on all newly installed Jenkins instances:
javaOpts: "...other options -Dorg.jenkinsci.plugins.pipeline.modeldefinition.parser.RuntimeASTTransformer.SCRIPT_SPLITTING_TRANSFORMATION=true"