【发布时间】:2023-03-17 12:48:01
【问题描述】:
我是 groovy 的新手,目前正在尝试将我的团队 Jenkins 服务器从 1.6 更新到 2.7。我需要迁移的部分之一是我们在版本控制中拥有的 Job DSL。
在新服务器上尝试运行旧作业 DSL 时出现以下错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/apps/Jenkins/workspace/DSL-infrastructure/shared/Shared.groovy: 10: Apparent variable 'com' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a class name or statically imported field. Please check the spelling.
You attempted to use a method 'com' but left out brackets in a place not allowed by the grammar.
@ line 10, column 17.
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
^
基本上,我认为问题在于 groovy 脚本找不到 com.cloudbees... 包。
Shared.groovy 脚本部分:
static def getCred(partialName) {
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
jenkins.model.Jenkins.instance,
null,
null
)
creds.find { it.description.contains(partialName) }
}
我已经到处搜索了,但我终其一生都无法弄清楚为什么或如何解决这个丢失的包裹问题。当我在 apache tomcat 中运行 Jenkins 时,它变得很复杂。
我不确定如何在运行 Jenkins 的 apache tomcat 服务器中导入这个丢失的包?我在目录中找到了 .jar 文件:
/apps/jenkins/plugins/credentials/WEB-INF/lib/credentials.jar
我试图引用的特定类:
任何帮助将不胜感激
【问题讨论】:
标签: tomcat groovy jenkins-job-dsl