How to remove old builds in jenkins? [duplicate]

2019-04-29 22:10发布

问题:

This question already has an answer here:

  • Jenkins: remove old builds with command line 8 answers

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?

回答1:

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.



回答2:

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.