Situation
QuickBuild ships with two build auto-cleanup strategies of a configuration:
- To reserve builds by certain number of days.
- To reserve certain number of builds.
However sometimes this is not enough. For instance, you may want that recommended builds never get deleted automatically while other builds follow the normal auto-cleanup strategy. The solution is to define maintenance configuration running at descired schedule running customized script to do the cleanup.
Demonstration
- Visit the demo configuration
, and hit the run button several times to generate more than five builds.
- Mark eldest build of the demo configuration
as recommended if it is not.
- Visit the demo cleanup configuration
, and hit the run button to perform cleanup for the demo configuration. The cleanup is intended to preserve latest three builds, with recommended builds remaining intacted.
- After cleanup, check the demo configuration
, and you will find that all recommended builds are still there, but only latest three builds of other statuses are preserved.
Resolution
- Switch to step setting of the demo cleanup configuration
. The master step is defined to execute a groovy script. The script loops over all builds of the demo configuration and delete all builds matching two conditions: not a recommended build and not the most recent three builds.
- The demo cleanup configuration is also scheduled to run every night at 1:00AM to do the job automatically.