From ac93fbe8f97737e771d89be6c1b450ba632b4ae7 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 30 Mar 2008 16:01:24 +0000 Subject: [PATCH] [fixed] display what's blocking the matrix configuration build in 1.202. (issue #1455) git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8115 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/matrix/MatrixBuild.java | 33 +++++++++++++++++-- .../matrix/MatrixBuild/ajaxMatrix.jelly | 2 +- .../hudson/matrix/MatrixBuild/main.jelly | 3 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/matrix/MatrixBuild.java b/core/src/main/java/hudson/matrix/MatrixBuild.java index 7c9932ae31..0e7999079f 100644 --- a/core/src/main/java/hudson/matrix/MatrixBuild.java +++ b/core/src/main/java/hudson/matrix/MatrixBuild.java @@ -39,10 +39,21 @@ public class MatrixBuild extends AbstractBuild { super(project, buildDir); } + /** + * Used by view to render a ball for {@link MatrixRun}. + */ public final class RunPtr { public final Combination combination; private RunPtr(Combination c) { this.combination=c; } public MatrixRun getRun() { return MatrixBuild.this.getRun(combination); } + public String getTooltip() { + MatrixRun r = getRun(); + if(r!=null) return r.getIconColor().getDescription(); + Queue.Item item = Hudson.getInstance().getQueue().getItem(getParent().getItem(combination)); + if(item!=null) + return item.getWhy(); + return null; // fall back + } } public Layouter getLayouter() { @@ -133,7 +144,7 @@ public class MatrixBuild extends AbstractBuild { try { for(MatrixConfiguration c : activeConfigurations) { - logger.println(Messages.MatrixBuild_Triggering(c.getName())); + logger.println(Messages.MatrixBuild_Triggering(c.getDisplayName())); c.scheduleBuild(); } @@ -142,6 +153,9 @@ public class MatrixBuild extends AbstractBuild { Result r = Result.SUCCESS; for (MatrixConfiguration c : activeConfigurations) { + String whyInQueue = ""; + long startTime = System.currentTimeMillis(); + // wait for the completion while(true) { MatrixRun b = c.getBuildByNumber(n); @@ -151,8 +165,9 @@ public class MatrixBuild extends AbstractBuild { Result buildResult = null; if(b!=null && !b.isBuilding()) buildResult = b.getResult(); - if(b==null && !c.isInQueue()) { - // there's conceivably a race condition here, sine b is set early on, + Queue.Item qi = c.getQueueItem(); + if(b==null && qi==null) { + // there's conceivably a race condition here, since b is set early on, // and we are checking c.isInQueue() later. A build might have started // after we computed b but before we checked c.isInQueue(). So // double-check 'b' to see if it's really not there. Possibly related to @@ -171,12 +186,24 @@ public class MatrixBuild extends AbstractBuild { if(!a.endRun(b)) return Result.FAILURE; break; + } else { + if(qi!=null) { + // if the build seems to be stuck in the queue, display why + String why = qi.getWhy(); + if(!why.equals(whyInQueue) && System.currentTimeMillis()-startTime>5000) { + logger.println(c.getDisplayName()+" is still in the queue: "+why); + whyInQueue = why; + } + } } Thread.sleep(1000); } } return r; + } catch( InterruptedException e ) { + logger.println("Aborted"); + return Result.ABORTED; } finally { // if the build was aborted in the middle. Cancel all the configuration builds. Queue q = Hudson.getInstance().getQueue(); diff --git a/core/src/main/resources/hudson/matrix/MatrixBuild/ajaxMatrix.jelly b/core/src/main/resources/hudson/matrix/MatrixBuild/ajaxMatrix.jelly index e4c984cd94..f4618472d1 100644 --- a/core/src/main/resources/hudson/matrix/MatrixBuild/ajaxMatrix.jelly +++ b/core/src/main/resources/hudson/matrix/MatrixBuild/ajaxMatrix.jelly @@ -5,7 +5,7 @@ - + diff --git a/core/src/main/resources/hudson/matrix/MatrixBuild/main.jelly b/core/src/main/resources/hudson/matrix/MatrixBuild/main.jelly index 2c6e2dc61d..a5499b4413 100644 --- a/core/src/main/resources/hudson/matrix/MatrixBuild/main.jelly +++ b/core/src/main/resources/hudson/matrix/MatrixBuild/main.jelly @@ -1,3 +1,4 @@ - \ No newline at end of file + \ No newline at end of file -- GitLab