Jenkins清理构建历史-八零岁月
记录所见
分享所感

Jenkins清理构建历史

def numberOfBuildsToKeep = 10
Jenkins.instance.getAllItems(AbstractItem.class).each {
  if( it.class.toString() !="class com.cloudbees.hudson.plugins.folder.Folder" && it.class.toString() !="class org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") {
    println it.name
    builds = it.getBuilds()
    for(int i = numberOfBuildsToKeep; i < builds.size(); i++) {
        builds.get(i).delete()
      println"Deleted" + builds.get(i)
    }
  }
}

文章转载请说明出处:八零岁月 » Jenkins清理构建历史

分享到:更多 ()

吐槽集中营 抢沙发

评论前必须登录!