提交 b1fe504b 编写于 作者: J jglick

[FIXED HUDSON-3227] Do not archive empty directories.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16026 71c3de6d-444a-0410-be80-ed276b4c234a
上级 c045600a
......@@ -942,6 +942,7 @@ public final class FilePath implements Serializable {
CopyImpl copyTask = new CopyImpl();
copyTask.setTodir(new File(target.remote));
copyTask.addFileset(Util.createFileSet(base,fileMask,excludes));
copyTask.setIncludeEmptyDirs(false);
copyTask.execute();
return copyTask.getNumCopied();
......
......@@ -24,12 +24,14 @@
package hudson.tasks;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.tasks.LogRotatorTest.TestsFail;
import java.io.File;
import static hudson.tasks.LogRotatorTest.build;
import java.io.IOException;
import java.util.Arrays;
......@@ -118,6 +120,34 @@ public class ArtifactArchiverTest extends HudsonTestCase {
assertTrue(project.getBuildByNumber(6).getHasArtifacts());
}
@Bug(3227)
public void testEmptyDirectories() throws Exception {
FreeStyleProject project = createFreeStyleProject();
Publisher artifactArchiver = new ArtifactArchiver("dir/", "", false);
project.getPublishersList().replaceBy(Collections.singleton(artifactArchiver));
project.getBuildersList().replaceBy(Collections.singleton(new TestBuilder() {
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath dir = build.getProject().getWorkspace().child("dir");
dir.child("subdir1").mkdirs();
FilePath subdir2 = dir.child("subdir2");
subdir2.mkdirs();
subdir2.child("file").write("content", "UTF-8");
return true;
}
}));
assertEquals(Result.SUCCESS, build(project)); // #1
File artifacts = project.getBuildByNumber(1).getArtifactsDir();
File[] kids = artifacts.listFiles();
assertEquals(1, kids.length);
assertEquals("dir", kids[0].getName());
kids = kids[0].listFiles();
assertEquals(1, kids.length);
assertEquals("subdir2", kids[0].getName());
kids = kids[0].listFiles();
assertEquals(1, kids.length);
assertEquals("file", kids[0].getName());
}
private static class CreateArtifact extends TestBuilder {
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
build.getProject().getWorkspace().child("f").write("content", "UTF-8");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册