Skip to content

Instantly share code, notes, and snippets.

@jb68
Created August 23, 2019 20:29
Show Gist options
  • Select an option

  • Save jb68/d411db6190890edf4a774cd2d3fcd3dd to your computer and use it in GitHub Desktop.

Select an option

Save jb68/d411db6190890edf4a774cd2d3fcd3dd to your computer and use it in GitHub Desktop.

Revisions

  1. jb68 created this gist Aug 23, 2019.
    4 changes: 4 additions & 0 deletions jen_del_blds.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    def jobName = "aa"
    def noOfJobsToKeep=5
    def job = Jenkins.instance.getItem(jobName)
    job.getBuilds().findAll { it.number < job.getBuilds().number.max() - noOfJobsToKeep }.each { it.delete() }