赞
踩
需要对jenkins做迁移,但是老的jenkins需要保留一段时间,先把老的jenkins所有job禁用掉
找到Manage Jenkins=>Script Console
输入下面的脚本
import hudson.model.*
disableChildren(Hudson.instance.items)
def disableChildren(items) {
for (item in items) {
if (item.class.canonicalName == 'com.cloudbees.hudson.plugins.folder.Folder') {
disableChildren(((com.cloudbees.hudson.plugins.folder.Folder) item).getItems())
} else if (item.class.canonicalName != 'org.jenkinsci.plugins.workflow.job.WorkflowJob') {
item.disabled=true
item.save()
println(item.name)
}
}
}
import hudson.model.* disableChildren(Hudson.instance.items) def disableChildren(items) { for (item in items) { if (item.class.canonicalName == 'com.cloudbees.hudson.plugins.folder.Folder') { disableChildren(((com.cloudbees.hudson.plugins.folder.Folder) item).getItems()) } else { item.disabled=true item.save() println(item.name) } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。