【Jenkins】一种闭包(函数嵌套)函数的Jenkinsfile写法,类似于Python的装饰器

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,python,运维)