[英]Jenkins Groovy post-build script to evaluate file with function
我在Jenkins工作的后期构建步骤中使用以下代码:
evaluate(new File("Set-BuildBadge.groovy"));
所以它成功运行的脚本,如果它不包含的功能。
如果在脚本中,我将定义一个函数 ,例如:
def addSummaryWithText(Icon, Text) {
manager.createSummary(Icon).appendText(Text, false)
}
...
addSummaryWithText("installer.gif", "Project: " + ProjectName)
然后我得到以下错误:
严重:类文件Set-BuildBadge $ addSummaryWithText java.lang.ClassFormatError中的非法类名“ Set-BuildBadge $ addSummaryWithText”:java.lang.ClassLoader中类文件Set-BuildBadge $ addSummaryWithText中的非法类名“ Set-BuildBadge $ addSummaryWithText” .defineClass1(本机方法)...
我不了解GroovyShell.evaluate的工作方式。 谁能帮我?
看起来JVM不喜欢其中带有连字符的类名。
通过在内部调用脚本Set-BuildBadge.groovy
,可Set-BuildBadge.groovy
其编译为在向脚本添加函数时不允许的类。
将脚本的名称更改为SetBuildBadge.groovy
可以解决它:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.