【Jenkins】Jenkins删除构建历史
作者:互联网
Jenkins删除构建历史
先贴一下脚本
删除单个项目的构建历史
def jobName = "Mall_qa"
def maxNumber = 39
Jenkins.instance.getItemByFullName(jobName).builds.findAll {
it.number <= maxNumber
}.each {
it.delete()
}
删除所有项目的构建历史并重置build number
#1
Jenkins.instance.getAllItems(AbstractProject.class).each {
item = Jenkins.instance.getItemByFullName(it.fullName)
item.builds.each() { build ->
build.delete()
}
item.updateNextBuildNumber(1)
}
#2
Jenkins.instance.allItems.each() {
item -> item.builds.each() {
build -> build.delete()
}
item.updateNextBuildNumber(1)
}
具体执行方法
- 打开Jenkins首页
- 选择菜单Manage Jenkins
- 进入Script Console
- 贴入脚本后运行
标签:builds,删除,item,instance,构建,build,each,Jenkins 来源: https://blog.csdn.net/zxtswcx/article/details/121921350