此问题与其他类似问题不同,因为它涉及使用gradle和Jenkins。
当我在开发环境中使用JDK 7构建我的gradle项目时,它构建得很好。当我在Jenkins CI环境中构建时,compileJava任务失败。
这是堆栈跟踪:
14:27:34.875 [ERROR] [system.err] The system is out of resources.
14:27:34.876 [ERROR] [system.err] Consult the following stack trace for details.
14:27:34.876 [ERROR] [system.err] java.lang.OutOfMemoryError: GC overhead limit exceeded
14:27:34.876 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.signature(MemberEnter.java:372)
14:27:34.876 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.visitMethodDef(MemberEnter.java:576)
14:27:34.876 [ERROR] [system.err] at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:669)
14:27:34.876 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:401)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:413)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.finishClass(MemberEnter.java:423)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.finish(MemberEnter.java:1066)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1026)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.code.Symbol.complete(Symbol.java:421)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:821)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:764)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:163)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:158)
14:27:34.877 [ERROR] [system.err] at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1063)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:1227)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:2392)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:2283)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1677)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:2247)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1677)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
14:27:34.878 [ERROR] [system.err] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:449)
14:27:34.879 [ERROR] [system.err] at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:214)
14:27:34.879 [ERROR] [system.err] at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:181)
14:27:34.879 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.enterAnnotations(MemberEnter.java:783)
14:27:34.885 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter.access$300(MemberEnter.java:57)
14:27:34.885 [ERROR] [system.err] at com.sun.tools.javac.comp.MemberEnter$5.enterAnnotation(MemberEnter.java:751)
14:27:34.885 [ERROR] [system.err] at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:109)
14:27:34.886 [ERROR] [system.err] at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:101)
14:27:34.886 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':my-platform:compileMySrcJava'
我尝试使用envInject插件在Jenkins中设置环境变量,如下所示:
[EnvInject] - Injecting as environment variables the properties content
JAVA_OPTIONS=-XX:-UseGCOverheadLimit -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -Xms128m -Xmx2048m
GRADLE_OPTS=-XX:-UseGCOverheadLimit -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -Xms128m -Xmx2048m
这似乎没有效果。
有关尝试什么的建议吗?
答案 0 :(得分:0)
问题被缩小到JDK1.7.0_79的Jenkins安装中。虽然我不知道底层问题是什么,但当我切换到使用JDK1.6.0_43的Jenkins安装时问题就消失了。并非每个项目都可以灵活地执行相同的解决方法。