Jenkins 管道脚本因“类生成期间的一般错误:方法代码太大!"而失败 [英] Jenkins pipeline script fails with "General error during class generation: Method code too large!"

查看:11
本文介绍了Jenkins 管道脚本因“类生成期间的一般错误:方法代码太大!"而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行大型 Jenkins 流水线脚本时,会报错:

When running a large Jenkins pipeline script, it can give the error:

org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:类生成期间的一般错误:方法代码太大!

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

java.lang.RuntimeException: 方法代码太大!

java.lang.RuntimeException: Method code too large!

此错误的原因是什么?如何解决?

What is the reason for this error and how can it be fixed?

推荐答案

这是由于 Java 和 Groovy 之间的限制,要求方法字节码不大于 64kb.这不是因为 Jenkins Pipeline DSL.

This is due to a limit between Java and Groovy, requiring that method bytecode be no larger than 64kb. It is not due to the Jenkins Pipeline DSL.

要解决这个问题,不要使用单一的整体管道脚本,而是将其分解为方法并调用这些方法.

To solve this, instead of using a single monolithic pipeline script, break it up into methods and call the methods.

例如,而不是:

stage foo
parallel([
 ... giant list of maps ...
])

改为:

stage foo
def build_foo() {
  parallel([
     ...giant list of maps...
  ])}
build_foo()

这篇关于Jenkins 管道脚本因“类生成期间的一般错误:方法代码太大!"而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆