Jenkins 脚本命令行常用示例
清除历史构建记录
1
2
3
4
5
6
7
8def jobName = "validator_server" // 项目名称
def maxNumber = 95 // 删除小于95的构建历史
Jenkins.instance.getItemByFullName(jobName).builds.findAll {
it.number <= maxNumber
}.each {
it.delete()
}重置 BUILD ID
1
2
3
4
5
6
7
8
9def jobName = "validator_server"
item = Jenkins.instance.getItemByFullName(jobName)
//THIS WILL REMOVE ALL BUILD HISTORY
item.builds.each() { build ->
build.delete()
}
item.updateNextBuildNumber(1)