提交 a3f0a992 编写于 作者: K kohsuke

Manually wiping out a workspace from GUI can cause NPE with some SCM plugins.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20934 71c3de6d-444a-0410-be80-ed276b4c234a
上级 237f1e27
......@@ -335,10 +335,20 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* @since 1.319
*/
public final FilePath getSomeWorkspace() {
R b = getSomeBuildWithWorkspace();
return b!=null ? b.getWorkspace() : null;
}
/**
* Gets some build that has a live workspace.
*
* @return null if no such build exists.
*/
public final R getSomeBuildWithWorkspace() {
int cnt=0;
for (R b = getLastBuild(); cnt<5 && b!=null; b=b.getPreviousBuild()) {
FilePath ws = b.getWorkspace();
if (ws!=null) return ws;
if (ws!=null) return b;
}
return null;
}
......@@ -1342,9 +1352,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*/
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
checkPermission(BUILD);
getLastBuild();
if (getScm().processWorkspaceBeforeDeletion(this, getWorkspace(), null)) {
getWorkspace().deleteRecursive();
R b = getSomeBuildWithWorkspace();
FilePath ws = b!=null ? b.getWorkspace() : null;
if (ws!=null && getScm().processWorkspaceBeforeDeletion(this, ws, b.getBuiltOn())) {
ws.deleteRecursive();
return new HttpRedirect(".");
} else {
// If we get here, that means the SCM blocked the workspace deletion.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册