提交 4cd8c409 编写于 作者: K Kristian Rosenvold

Added reason for why we are rebuilding to the log message

上级 5e8d0b65
...@@ -1434,13 +1434,15 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A ...@@ -1434,13 +1434,15 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
// lock the workspace of the last build // lock the workspace of the last build
FilePath ws=lb.getWorkspace(); FilePath ws=lb.getWorkspace();
if (workspaceOffline(lb)) { WorkspaceOfflineReason workspaceOfflineReason = workspaceOffline( lb );
if ( workspaceOfflineReason != null ) {
// workspace offline. build now, or nothing will ever be built // workspace offline. build now, or nothing will ever be built
Label label = getAssignedLabel(); Label label = getAssignedLabel();
if (label != null && label.isSelfLabel()) { if (label != null && label.isSelfLabel()) {
// if the build is fixed on a node, then attempting a build will do us // if the build is fixed on a node, then attempting a build will do us
// no good. We should just wait for the slave to come back. // no good. We should just wait for the slave to come back.
listener.getLogger().println(Messages.AbstractProject_NoWorkspace()); listener.getLogger().print(Messages.AbstractProject_NoWorkspace());
listener.getLogger().println( " (" + workspaceOfflineReason.name() + ")");
return NO_CHANGES; return NO_CHANGES;
} }
listener.getLogger().println( ws==null listener.getLogger().println( ws==null
...@@ -1450,7 +1452,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A ...@@ -1450,7 +1452,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
listener.getLogger().println(Messages.AbstractProject_AwaitingBuildForWorkspace()); listener.getLogger().println(Messages.AbstractProject_AwaitingBuildForWorkspace());
return NO_CHANGES; return NO_CHANGES;
} else { } else {
listener.getLogger().println(Messages.AbstractProject_NewBuildForWorkspace()); listener.getLogger().print(Messages.AbstractProject_NewBuildForWorkspace());
listener.getLogger().println( " (" + workspaceOfflineReason.name() + ")");
return BUILD_NOW; return BUILD_NOW;
} }
} else { } else {
...@@ -1486,22 +1489,28 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A ...@@ -1486,22 +1489,28 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
} }
} }
private boolean workspaceOffline(R build) throws IOException, InterruptedException { enum WorkspaceOfflineReason {
nonexisting_workspace,
builton_node_gone,
builton_node_no_executors
}
private WorkspaceOfflineReason workspaceOffline(R build) throws IOException, InterruptedException {
FilePath ws = build.getWorkspace(); FilePath ws = build.getWorkspace();
if (ws==null || !ws.exists()) { if (ws==null || !ws.exists()) {
return true; return WorkspaceOfflineReason.nonexisting_workspace;
} }
Node builtOn = build.getBuiltOn(); Node builtOn = build.getBuiltOn();
if (builtOn == null) { // node built-on doesn't exist anymore if (builtOn == null) { // node built-on doesn't exist anymore
return true; return WorkspaceOfflineReason.builton_node_gone;
} }
if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t. if (builtOn.toComputer() == null) { // node still exists, but has 0 executors - o.s.l.t.
return true; return WorkspaceOfflineReason.builton_node_no_executors;
} }
return false; return null;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册