提交 3b8a0044 编写于 作者: K kohsuke

applied a patch for #1348


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7732 71c3de6d-444a-0410-be80-ed276b4c234a
上级 bc447063
......@@ -588,19 +588,24 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
try {
FilePath workspace = getWorkspace();
if(workspace==null) {
// workspace offline. build now, or nothing will ever be built
listener.getLogger().println(Messages.AbstractProject_WorkspaceOffline());
return true;
}
if(!workspace.exists()) {
// no workspace. build now, or nothing will ever be built
listener.getLogger().println(Messages.AbstractProject_NoWorkspace());
return true;
}
return scm.pollChanges(this, workspace.createLauncher(listener), workspace, listener );
FilePath workspace = getWorkspace();
if (scm.requiresWorkspaceForPolling()) {
if(workspace==null) {
// workspace offline. build now, or nothing will ever be built
listener.getLogger().println("Workspace is offline.");
listener.getLogger().println("Scheduling a new build to get a workspace.");
return true;
}
if(!workspace.exists()) {
// no workspace. build now, or nothing will ever be built
listener.getLogger().println("No workspace is available, so can't check for updates.");
listener.getLogger().println("Scheduling a new build to get a workspace.");
return true;
}
}
Launcher launcher = workspace != null ? workspace.createLauncher(listener) : null;
return scm.pollChanges(this, launcher, workspace, listener );
} catch (AbortException e) {
listener.fatalError(Messages.AbstractProject_Aborted());
return false;
......
......@@ -80,6 +80,26 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint {
public boolean supportsPolling() {
return true;
}
/**
* Returns true if this SCM requires a checked out workspace for doing polling.
*
* <p>
* This flag affects the behavior of Hudson when a job lost its workspace
* (typically due to a slave outage.) If this method returns false and
* polling is configured, then that would immediately trigger a new build.
*
* <p>
* The default implementation returns true.
*
* <p>
* See issue #1348 for more discussion of this feature.
*
* @since 1.196
*/
public boolean requiresWorkspaceForPolling() {
return true;
}
/**
* Checks if there has been any changes to this module in the repository.
......
......@@ -55,6 +55,7 @@ import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNInfo;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNStatus;
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
import org.tmatesoft.svn.core.wc.SVNWCClient;
import org.tmatesoft.svn.core.wc.SVNWCUtil;
......@@ -1355,4 +1356,12 @@ public class SubversionSCM extends SCM implements Serializable {
ch.ethz.ssh2.log.Logger.logLevel = 100;
}
/**
* Polling can happen on the master and does not require a workspace.
*/
@Override
public boolean requiresWorkspaceForPolling() {
return false;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册