[Jenkins] Cleanup Build History

less than 1 minute read

1. Using Jenkins Script Console

  • Manage Jenkins > Script Console

ScriptConsole

All Jobs

Jenkins.instance.getAllItems().each() { job ->
  job.builds.each() { build ->
    build.delete()
  }

  job.updateNextBuildNumber(1)
}

Specific Job

job = Jenkins.instance.getItemByFullName("job_name")

job.builds.each() { build ->
  build.delete()
}

job.updateNextBuildNumber(1)

Leave a comment