Skip to main content
Version: QB11

Complicated Build Cleanup Strategy

Situation

QuickBuild ships with two build auto-cleanup strategies of a configuration:

  1. To reserve builds by certain number of days.
  2. 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

  1. Visit the demo configuration, and hit the run button several times to generate more than five builds.
  2. Mark eldest build of the demo configuration as recommended if it is not.
  3. 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.
  4. 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

  1. 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.
  2. The demo cleanup configuration is also scheduled to run every night at 1:00AM to do the job automatically.