我的jenkins-shared-libraries
结构是这样的:
vars
|_mainPipeline.groovy
resources
src
|_ com
|_company
|_utils.groovy
|_data.groovy
实用程序.groovy:
package com.company;
def getCommitHash() {
return "somestring"
}
return this
数据.groovy:
package com.company;
def utils = new com.company.utils()
def doSomeStuff() {
def commitHash = utils.getCommitHash()
// Do other stuff...
}
return this
mainPipeline.groovy: 数据.groovy:
def utils = new com.company.utils()
pipeline {
....
def commitHash = utils.getCommitHash()
}
导入效果很好,但是,当我导入它时utils
出现异常:mainPipeline
data.groovy
groovy.lang.MissingPropertyException: No such property: utils for class: groovy.lang.Binding
utils
里面怎么用data
?谢谢。