Maps.<AbstractProject, Cause>newHashMap();
Set<AbstractProject> completed = Sets.<AbstractProject>newHashSet();
int maxRetries = masterBuild.getMaxRetries();
do {
for (AbstractProject project : projects) {
AbstractBuild build = projectBuildMap.get(project);
if (build != null) {
if (build.isBuilding()) {
logger.printf("......... %s (%s%s%s)\n",
project.getDisplayName(),
hudson.getRootUrl(),
build.getUrl(),
"console");
} else if (!completed.contains(project)) {
Result result = build.getResult();
String page = "testReport";
if (result.isWorseThan(Result.UNSTABLE)) {
page = "console";
}
logger.printf("[%s] %s (%s%s%s)\n",
result,
project.getDisplayName(),
hudson.getRootUrl(),
build.getUrl(),
page);
MasterBuildCause currentCause =
(MasterBuildCause) build.getCause(MasterBuildCause.class);
int rebuildNumber = currentCause.getRebuildNumber();
if (result.isWorseThan(Result.SUCCESS)
&& rebuildNumber < maxRetries) {
Cause newCause =
new MasterBuildCause(masterBuild, rebuildNumber + 1);
this.masterBuild.rebuild(project, newCause);
projectBuildMap.remove(project);
causeMap.put(project, newCause);
logger.printf("!!!REBUILDING!!! %s (%s%s%s)\n",
project.getDisplayName(),
hudson.getRootUrl(),
build.getUrl(),
page);
} else {
completed.add(project);
}
}
} else {
Cause cause = causeMap.containsKey(project)
? causeMap.get(project) : this.cause;
build = buildFinder.findBuild(project, cause);
if (build != null) {
masterBuild.addSubBuild(
project.getDisplayName(),
build.getNumber());
projectBuildMap.put(project, build);
} else {
logger.printf(
"......... %s (pending)\n",
project.getDisplayName());