java.lang.StackOverflowError 在使用 emailext 插件时

java.lang.StackOverflowError while using emailext plugin

在我的管道结束时,我想发送一封邮件来查看我的构建是否成功。因此,我使用以下 groovy 脚本:

emailext (
to: 'mail@example.com',
subject: 'Job: ' + env.JOB_NAME + ' / ' +'Build #' + env.BUILD_NUMBER + ' / ' + ' Summary',
body:'Integrity Checkout: '+ '\t\t\t' + checkoutStatus +'\n\n' + 'Build1: '+ '\t\t\t' + Build1 + '\n' 
                                                       + 'Build2 :'+ '\t' + Build2 + '\n'
                                                       + 'Build3 :'+ '\t' + Build3 + '\n'
                                                       + 'Build4 :'+ '\t' + Build4 + '\n'
                                                       + 'Build5 :'+ '\t' + Build5 + '\n'
                                                       + 'Build6 :'+ '\t' + Build6 + '\n'
                                                       + 'Build7 :'+ '\t' + Build7 + '\n'
                                                       + 'Build8 :'+ '\t' + Build8 + '\n'
                                                       + 'Build9 :'+ '\t' + Build9 + '\n'
                                                       + 'Build10:'+ '\t' + Build10 + '\n'
                                                       + 'Build11:'+ '\t' + Build11 + '\n'
                                                       + 'Build12:'+ '\t' + Build12 + '\n'
                                                       + 'Build13:'+ '\t' + Build13 + '\n'
                                                       + 'Build14:'+ '\t' + Build14 + '\n'
                                                       + 'Build15:'+ '\t' + Build15 + '\n'
                                                       + 'Build16:'+ '\t' + Build16,
attachLog: true,
compressLog: true
)

基本上代码可以工作,但前提是我注释掉最后一行 (build16)。变量已正确分配。但是如果我执行代码,我会得到 java.lang.WhosebugError。 (超过 1000 行)

短截:

java.lang.WhosebugError
at java.lang.Exception.<init>(Unknown Source)
at java.lang.ReflectiveOperationException.<init>(Unknown Source)
at java.lang.reflect.InvocationTargetException.<init>(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4094.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at com.cloudbees.groovy.cps.CpsTransformer$_visitBinaryExpression_closure26.doCall(CpsTransformer.groovy)
at sun.reflect.GeneratedMethodAccessor4092.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.groovy:355)
at sun.reflect.GeneratedMethodAccessor3945.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.groovy:330)
at sun.reflect.GeneratedMethodAccessor3944.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
at com.cloudbees.groovy.cps.CpsTransformer.visitBinaryExpression(CpsTransformer.groovy:636)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51)
at org.codehaus.groovy.ast.expr.BinaryExpression$visit.call(Unknown Source)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.groovy:290)
at sun.reflect.GeneratedMethodAccessor3946.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at com.cloudbees.groovy.cps.CpsTransformer$_visitBinaryExpression_closure26.doCall(CpsTransformer.groovy:630)
at sun.reflect.GeneratedMethodAccessor4094.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at com.cloudbees.groovy.cps.CpsTransformer$_visitBinaryExpression_closure26.doCall(CpsTransformer.groovy)
at sun.reflect.GeneratedMethodAccessor4092.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.groovy:355)
at sun.reflect.GeneratedMethodAccessor3945.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.groovy:330)
at sun.reflect.GeneratedMethodAccessor3944.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
at com.cloudbees.groovy.cps.CpsTransformer.visitBinaryExpression(CpsTransformer.groovy:636)
at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51)
at org.codehaus.groovy.ast.expr.BinaryExpression$visit.call(Unknown Source)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.groovy:290)
at sun.reflect.GeneratedMethodAccessor3946.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

问题解决了。大量的“+”运算符导致了溢出。现在我正在使用 java.lang.StringBuilder.append 来构建我的输出字符串。