How do I clear my Jenkins/Hudson build history?

后端 未结 14 1694
醉话见心
醉话见心 2020-12-07 08:10

I recently updated the configuration of one of my hudson builds. The build history is out of sync. Is there a way to clear my build history?

Please and thank you

14条回答
  •  余生分开走
    2020-12-07 08:23

    Deleting directly from file system is not safe. You can run the below script to delete all builds from all jobs ( recursively ).

    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)
        }
      }
    }
    

提交回复
热议问题