9

I removed old build folders from the build directory in Jenkins expecting them to be removed in the UI, unfortunately whilse these build directories are gone, their UI link still exists. I now have two questions:

  1. How can I get rid of the defunct links in the UI?
  2. How can I delete old build from cli and have it reflected in the UI?
peterh
  • 11,875
  • 18
  • 85
  • 108
Dark Star1
  • 6,986
  • 16
  • 73
  • 121
  • As of Jenkins 1.626 this answer: http://stackoverflow.com/a/13052966/107301 works – Dark Star1 Nov 09 '15 at 08:32
  • 2
    In Jenkins 2+ (mine is 2.89) in the Config of every Job there is now an option "Discard Old Builds" where you can specify if you want to delete builds older than X days and/or only keep X latest builds – Andrejs Feb 06 '18 at 08:01

2 Answers2

12

A better way to remove old builds is discard-old-build plugin where you can specify how many builds you want to keep and all older builds are discarded.

Devesh
  • 856
  • 5
  • 15
  • Thanks. I will install that but I still need to get rid of the current mess. – Dark Star1 Nov 06 '15 at 15:54
  • 1
    Yes after the plugin is installed, set the number of builds you want to keep and run a fresh build. It will then cleanup all the older builds from the UI. – Devesh Nov 06 '15 at 16:05
  • 2
    This answer does not resolve the original issue. As pointed out by Dark Star1 in the comment above the question was how to reconcile the deleted builds on the file system with what Jenkins displays. The discard-old-builds plugin can be used proactively to establish policies to decide how many builds to keep in the future, but will not refresh the web application. – rgulia Jul 31 '17 at 01:46
  • 1
    Make sure to read the comments on the plugin page. Lots of people seem to have issues with missing / lost data. – Markus Feb 21 '19 at 08:15
  • Or [build history manager](https://github.com/jenkinsci/build-history-manager-plugin) plugin – Damian Sep 10 '21 at 13:48
7

You must either restart Jenkins or reload the data, in order to reconcile the UI with its back end. There is no other way.

If you have access to the "Manage Jenkins" menu there is a link to "Reload Configuration from Disk", which is a little less invasive than a restart.

Keep in mind that the system will be not usable for a few seconds while the data is reloaded, just like during a full restart. If you have a lot of builds, this might take a little. So, make sure that this is ok with the other users of your system.

rgulia
  • 523
  • 7
  • 11