Jenkins:重置 job build number

发布时间 2023-08-01 18:54:08作者: Apple Zhang

在调试jenkins job时会产生很多fail的build,很多红色的X还是很碍眼的,job调试成功后就可以重置build number了。

步骤:

  1. 点击jenkins小老头图标 -> 管理Jenkins

  2. 管理Jenkins页面找到Tools and Actions -> scripts console工具

  3. 运行下面代码

def jobName = "需重置build号的job名称"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()

参考:https://linuxhelp4u.blogspot.com/2018/03/how-to-clean-or-reset-build-numbers-in.html