基本上,没有多余的废话,我无法将构建属性传递给Library var调用。
jenkinsfile相关的块:
tc_test{
repo = 'test1'
folder = 'test2'
submodules = true
refs = params.GitCheckout
}
Run Code Online (Sandbox Code Playgroud)
导致错误
java.lang.NullPointerException:无法在空对象上获取属性'GitCheckout'
但是,这有效:
def a1 = params.GitCheckout
tc_test{
repo = 'test1'
folder = 'test2'
submodules = true
refs = a1
}
Run Code Online (Sandbox Code Playgroud)
共享库中vars / tc_test.groovy的内容:
def call ( body ) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
try {
body()
} catch(e) {
currentBuild.result = "FAILURE";
throw e;
} finally {
config.each{ k, v -> println "${k}:${v}" }
}
} …Run Code Online (Sandbox Code Playgroud)