Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
Implement isBuilding() to show the flashing orb from the start.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash Parghi committed Oct 20, 2014
1 parent 66e5f6d commit 653b718
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/main/java/com/etsy/jenkins/MasterBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,24 @@
import hudson.model.AbstractProject;
import hudson.model.Build;
import hudson.model.Cause;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.Result;
import hudson.model.Run;
import hudson.security.Permission;

import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Provider;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.Future;
import javax.servlet.ServletException;
import org.kohsuke.stapler.HttpResponse;

public class MasterBuild extends Build<MasterProject, MasterBuild> {

Expand Down Expand Up @@ -106,6 +101,15 @@ public Result getResult() {
return result;
}

@Override
public boolean isBuilding() {
if (super.isBuilding()) {
// If this build's executor is running, defer to that.
return true;
}
return this.masterResult.isBuilding();
}

/*package*/ void addSubBuild(String projectName, int buildNumber) {
masterResult.addBuild(projectName, buildNumber);

Expand All @@ -124,7 +128,7 @@ public List<AbstractBuild> getLatestBuilds() {
public void rebuild(AbstractProject project) throws ServletException {
if (!getSubProjects().contains(project)) {
throw new ServletException(
"Not a sub-project of this master build: "
"Not a sub-project of this master build: "
+ project.getDisplayName());
}

Expand All @@ -150,12 +154,12 @@ public void doRefreshLatestBuilds(StaplerRequest req, StaplerResponse res)
}

@Override
public void doStop(StaplerRequest req, StaplerResponse res)
public HttpResponse doStop()

This comment has been minimized.

Copy link
@yparghi

yparghi Oct 20, 2014

Contributor

I switched to the non-deprecated version of this method.

throws IOException, ServletException {
for (Future<AbstractBuild> future : futuresToAbort) {
future.cancel(true);
}
super.doStop(req, res);
return super.doStop();
}
}

13 changes: 13 additions & 0 deletions src/main/java/com/etsy/jenkins/MasterResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,18 @@ public Result getOverallResult() {
}
return endResult;
}

public boolean isBuilding() {
if (results.isEmpty()) {
// No builds have been scheduled yet.
return true;
}
for (SubResult subResult : results.values()) {
if (subResult.getLatestBuild().isBuilding()) {
return true;
}
}
return false;
}
}

0 comments on commit 653b718

Please sign in to comment.