【发布时间】:2018-08-09 19:22:48
【问题描述】:
我有以下 groovy 代码:
def script
String credentials_id
String repository_path
String relative_directory
String repository_url
CredentialsWrapper(script, credentials_id, repository_name, repository_group, relative_directory=null) {
this(script, credentials_id, 'git@gitlab.foo.com:' + repository_group +'/' + repository_name + '.git', relative_directory);
}
CredentialsWrapper(script, credentials_id, repository_url, relative_directory=null) {
this.script = script;
this.credentials_id = credentials_id;
this.repository_url = repository_url;
if (null == relative_directory) {
int lastSeparatorIndex = repository_url.lastIndexOf("/");
int indexOfExt = repository_url.indexOf(".git");
this.relative_directory = repository_url.substring(lastSeparatorIndex+1, indexOfExt);
}
}
Jenkins 给了我以下信息:
由于构造函数 @ 第 30 行第 7 列中的哈希冲突,无法编译 com.foo.CredentialsWrapper 类。
我不明白为什么,构造函数不同,它们的参数数量不同。
另外,“script”是“WorkflowScript”的一个实例,但我不知道我应该导入什么来访问这个类,这将允许我显式声明脚本而不是使用“def”
有什么想法吗?
【问题讨论】:
标签: groovy hash constructor collision