The built-in strategy in QuickBuild only supports to preserve certain amount or days of builds. Sometimes it is necessary to preserve all recommended builds also. In this case, turn off the default cleanup strategy, and schedule a maintenance configuration running below script:
groovy:
def confToCleanup = system.getConfiguration("path/to/conf_for_cleanup");
def daysToPreserve = 7;
for (eachBuild in system.buildManager.getBuilds(confToCleanup)) {
if (System.currentTimeMillis() - eachBuild.beginDate.time > daysToPreserve*24*3600*1000L && !build.recommended)
system.buildManager.delete(eachBuild);
}