Skip to content

Instantly share code, notes, and snippets.

@ConnerAiken
Created February 23, 2018 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConnerAiken/6dcf032c4e60fbc7f50a6c699ab5da87 to your computer and use it in GitHub Desktop.
Save ConnerAiken/6dcf032c4e60fbc7f50a6c699ab5da87 to your computer and use it in GitHub Desktop.
Jenkins - Clear build history

Usage

Login to jenkins with admin user. Click 'manage jenkins' then 'script console' and enter the above .txt file

// change this variable to match the name of the job whose builds you want to delete
def jobName = "Your Job Name"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
// uncomment these lines to reset the build number to 1:
//job.nextBuildNumber = 1
//job.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment