提交 470d9ce8 编写于 作者: P Pedro Rodriguez

Backwards compatibility added. Added allowEmptyArchive test

上级 3a202d13
......@@ -67,7 +67,13 @@ public class ArtifactArchiver extends Recorder {
/**
* Fail (or not) the build if archiving returns nothing.
*/
private final boolean allowEmptyArchive;
private Boolean allowEmptyArchive;
/**
* Compatibility for systems using the older setting.
*/
private static final Boolean allowEmptyArchiveSystemProp =
Boolean.getBoolean(ArtifactArchiver.class.getName()+".warnOnEmpty");
@DataBoundConstructor
public ArtifactArchiver(String artifacts, String excludes, boolean latestOnly, boolean allowEmptyArchive) {
......@@ -77,6 +83,14 @@ public class ArtifactArchiver extends Recorder {
this.allowEmptyArchive = allowEmptyArchive;
}
// Backwards compatibility for older builds
public Object readResolve() {
if (allowEmptyArchive == null) {
this.allowEmptyArchive = allowEmptyArchiveSystemProp;
}
return this;
}
public String getArtifacts() {
return artifacts;
}
......@@ -108,7 +122,7 @@ public class ArtifactArchiver extends Recorder {
build.setResult(Result.FAILURE);
return true;
}
File dir = build.getArtifactsDir();
dir.mkdirs();
......
......@@ -148,6 +148,14 @@ public class ArtifactArchiverTest extends HudsonTestCase {
assertEquals("file", kids[0].getName());
}
@Bug(10502)
public void testAllowEmptyArchive() throws Exception {
FreeStyleProject project = createFreeStyleProject();
project.getPublishersList().replaceBy(Collections.singleton(new ArtifactArchiver("f", "", false, true)));
assertEquals("(no artifacts)", Result.SUCCESS, build(project));
assertFalse(project.getBuildByNumber(1).getHasArtifacts());
}
static class CreateArtifact extends TestBuilder {
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
build.getWorkspace().child("f").write("content", "UTF-8");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册