超长的Jenkinsfile的Method code too large问题对应方法
在Jenkins中可以使用Groovy语言来编写符合Jenkins的流水线,但是内容多到一定程度上可能会出现Method code too large的错误提示信息,这篇文章介绍一下应对方法。
错误信息示例
Started by user root
Running in Durability level: MAX_SURVIVABILITY
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$17.call(CompilationUnit.java:827)at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)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.doParse(CpsGroovyShell.java:142)at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327)at hudson.model.ResourceController.execute(ResourceController.java:97)at hudson.model.Executor.run(Executor.java:429)1 errorat org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)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.doParse(CpsGroovyShell.java:142)at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327)at hudson.model.ResourceController.execute(ResourceController.java:97)at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE
相关的Jenkins Issue
- https://issues.jenkins-ci.org/browse/JENKINS-50033
此issue状态为closed,但是实际并未对应,是因为重复而关闭。 - https://issues.jenkins-ci.org/browse/JENKINS-37984
37894提的时间是2016年,50033提的时间是2018年,关闭的时间是2019年,实际上这个问题应该是从来都没有正式地解决过。
问题的原因
问题实际上应该不是Jenkins的问题,至少是跟Jenkins插件相关的问题,在将Groovy语言的流水线转化为字节码的时候,如果某一方法过大,JVM中会有64K的限制。
解决方法
在下述链接中找到了解决的一种方法:
- https://stackoverflow.com/questions/40049917/jenkins-pipeline-script-fails-with-general-error-during-class-generation-metho
一般情况下出现此问题的流水线代码结构如下所示:
node {stage('stage1') { stage具体代码 }stage('stage2') { stage具体代码 }...stage('stagen') { stage具体代码 }
}
所以出现超64k的情况一般是整个node中包含的内容过大,将各个stage的具体实现(stage具体代码)在node外进行函数的定义,而在stage中进行调用的方式即可解决此问题,一般来说修改即可一般就可以了,但是还是建议整体修改一下,这样代码阅读起来也更方便一些。
注意:参考链接中的方法的定义似乎有小问题,请根据所用的Jenkins版本的DSL格式进行修改。另外,这不是多行修改到一行上就可以避免的问题,为了阅读更加容易,建议还是进行分行。
超长的Jenkinsfile的Method code too large问题对应方法相关推荐
- java code large_Java中的“代码太大”编译错误(“Code too large” compilation error in Java)...
Java中的"代码太大"编译错误("Code too large" compilation error in Java) Java中的代码是否有最大大小? 我写 ...
- no identity found Command /usr/bin/codesign failed with exit code 1 报错解决方法
no identity found Command /usr/bin/codesign failed with exit code 1 报错解决方法 参考文章: (1)no identity foun ...
- java.lang.IllegalArgumentException: Request header is too large的解决方法
java.lang.IllegalArgumentException: Request header is too large的解决方法 参考文章: (1)java.lang.IllegalArgum ...
- 使用nginx做反代时遇到413 Request Entity Too Large的解决方法
使用nginx做反代时遇到413 Request Entity Too Large的解决方法 参考文章: (1)使用nginx做反代时遇到413 Request Entity Too Large的解决 ...
- VS Code刷力扣LeetCode方法
VS Code刷力扣LeetCode方法 一.LeetCode扩展安装 二.Node.js安装 三.账号登录 3.1 选择 力扣中国版 3.2 选择 Cookies方式登录 3.3 Cookies获取 ...
- Unable to register the DLL/OCX: RegSvr32 failed with exit code 0x3 我的解决方法
Unable to register the DLL/OCX: RegSvr32 failed with exit code 0x3 我的解决方法 参考文章: (1)Unable to registe ...
- 通过 IDEA 检查代码 Inspect Code,查找无用的方法、类等问题
文章目录 通过 IDEA 检查代码Inspect Code,查找无用的方法.类等问题 1.点击检查代码选项 2.结果 3.根据指定的检查项来检查代码 通过 IDEA 检查代码Inspect Code, ...
- VS code 的简单入门使用方法(汇总版本)
VS code 的简单入门使用方法 背景 本文仅仅将vs code 作为文本工具来用,并非将其作为IDE开发工具(替代类似Windows 中的Notepad++). 本文仅讨论 Mac 平台的 vs ...
- vs code显示大纲(函数方法列表)方法
vs code显示大纲(函数方法列表)方法 尝试了网上好几种办法: (1)vs code显示大纲(函数方法列表)为啥不好使 (2)vscode左下角显示大纲(显示所有函数方法) 发现都没效果,然后通过 ...
最新文章
- python快速排序解析_快速排序python实现总结
- Eclipse 修改所有文件默认编码为UTF-8
- CV:利用cv2自带两步法haarcascade_frontalcatface.xml实现对猫脸检测
- qt 实现拖动矩形角度_手机上如何使用CAD角度标注功能?
- Freemarker中如何遍历List
- ZK的实际应用:MVVM –以编程方式更新视图
- mysql 索引表的应用_MySQL查询优化之索引的应用详解
- POJ3233 Matrix Power Series
- 养老金8000元左右,身体好,无负担,怎样安排退休生活好呢?
- Qt——P20 模态和非模态对话框创建
- 表达式必须具有与对应表达式相同的数据类型_跟光磊学Java开发-运算符和表达式...
- UML交互图——鲁棒图的三元素:抽象对象,实体对象和控制对象
- Learning-MySQL【4】:表的操作管理和 MySQL 的约束控制
- Lucas-Kanade 20 Years On 正反向/累加/合成求解算法
- 已解决报错UnboundLocalError: local variable ‘title‘ referenced before assignment
- 海康威视API-单帧数据捕获并保存成JPEG图片NET_DVR_CaptureJPEGPicture
- 智能家居正进化成人们想要的样子
- 8月顺利拿到OPPO公司Android架构师offer,一面+部长面
- 重庆市计算机专业高考试题,职业高中高考计算机专业试卷5
- 南京理工大学c语言课程设计,南京理工大学C语言讲义第7章.ppt
热门文章
- 结合使用Ajax和Web服务
- 每天学习10句英语-第八天
- mysql 随机密码_MySQL 生成随机密码
- 【AI Studio】飞桨图像分类零基础训练营 - 0456 - 图像分类竞赛全流程实战
- “动动手指就搞定”——谈手势操作在手机端软件设计中的应用
- npm升级cnpm方法
- html微信拆红包动画特效,利用jQuery实现微信红包领取动画特效
- 大一计算机考试挂了怎么办,大一期末考试最容易挂科的课程,看起来简单,实则让考生头疼...
- 前端利用numeral处理数字和时间格式化
- python安装第三方包出现无法在安装目录中创建文件_解决pip安装的第三方包在PyCharm无法导入的问题...