繁体   English   中英

Jenkins Groovy生成后脚本用于评估具有功能的文件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM