批量处理Jenkins的job最简单的方法就是使用Jenkins的REST API接口操作,如下是一个禁用所有job的简单示例。
import jenkins.model.Jenkins
// Get the Jenkins instance
def jenkins = Jenkins.getInstance()
// Get all jobs
def jobs = jenkins.getItems()
// Iterate over each job and disable it
jobs.each { job ->
job.makeDisabled(true)
}
println "All jobs have been disabled."
评论前必须登录!
注册