def prepare(Map JOB, Closure body) {
dir('xxxxx') {
sh(script: "git update ${JOB.version}")
body()
}
}
// 调用方法1
prepare(version: "3asd8asd7a7ds") {
sh(script: "git commit")
}
def JOB = [
version: "3asd8asd7a7ds",
xxxx: "xxxx"
]
// 调用方法2
prepare(JOB) {
sh(script: "git commit")
}
【Jenkins】一种闭包(函数嵌套)函数的Jenkinsfile写法,类似于Python的装饰器
于 2025-02-26 17:27:23 首次发布