Skip to content
Permalink
Browse files
Merge pull request #14 from ikedam/feature/JENKINS-28585_ErrorWithNon…
…Aggregatable

[JENKINS-28585] Skips aggregation processing if no publisher supports aggregation.
  • Loading branch information
ikedam committed Jun 6, 2015
2 parents 2419aef + ab0a504 commit d487888d9793215ae18a87cae9700a9cff3fa0cc
Showing 2 changed files with 50 additions and 13 deletions.
@@ -207,26 +207,26 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
}

public ConditionalMatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) {
if (isConfiguredAggregation()) {
// alerts if all publishers doesn't support aggregation
// even if configured for aggregation
boolean supportAggregation = false;

for (BuildStep publisher: getPublisherList()) {
if (publisher instanceof MatrixAggregatable) {
supportAggregation = true;
break;
}
boolean supportAggregation = false;

for (BuildStep publisher: getPublisherList()) {
if (publisher instanceof MatrixAggregatable) {
supportAggregation = true;
break;
}

if (!supportAggregation) {
}

if (!supportAggregation) {
if (isConfiguredAggregation()) {
// alerts if all publishers doesn't support aggregation
// even if configured for aggregation
listener.getLogger().println(String.format(
"[%s] WARNING: Condition for Matrix Aggregation is configured for %s which does not support aggregation",
getDescriptor().getDisplayName(),
FlexiblePublisher.getBuildStepShortName(getPublisherList())
));
return null;
}
return null;
}
// First, decide whether the condition is satisfied
// in the parent scope.
@@ -31,6 +31,7 @@
import hudson.Extension;
import hudson.Launcher;
import hudson.matrix.AxisList;
import hudson.matrix.Combination;
import hudson.matrix.MatrixAggregatable;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixConfiguration;
@@ -63,6 +64,7 @@
import org.jenkins_ci.plugins.run_condition.BuildStepRunner;
import org.jenkins_ci.plugins.run_condition.core.AlwaysRun;
import org.jenkins_ci.plugins.run_condition.core.StringsMatchCondition;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;

/**
@@ -951,4 +953,39 @@ public void testRunAggregatorsWithFailFast() throws Exception {
assertNull(b.getAction(AggregationRecorder.AggregatorAction.class));
}
}

@Bug(28585)
public void testOnlyNonaggregateble() throws Exception {
MatrixProject p = createMatrixProject();
AxisList axisList = new AxisList(new TextAxis("axis1", "value1", "value2"));
p.setAxes(axisList);
p.getBuildersList().add(new FileWriteBuilder("artifact.txt", "blahblahblah"));
p.getPublishersList().add(new FlexiblePublisher(Arrays.asList(
new ConditionalPublisher(
new StringsMatchCondition("${axis1}", "value1", false),
Arrays.<BuildStep>asList(
new ArtifactArchiver("**/*", "", false)
),
new BuildStepRunner.Fail(),
false,
null,
null,
new FailFastExecutionStrategy()
)
)));

MatrixBuild build = p.scheduleBuild2(0).get();
assertBuildStatusSuccess(build);

{
MatrixRun r = build.getRun(new Combination(axisList, "value1"));
assertBuildStatusSuccess(r);
assertEquals(Arrays.asList("artifact.txt"), Arrays.asList(r.getArtifactsDir().list()));
}
{
MatrixRun r = build.getRun(new Combination(axisList, "value2"));
assertBuildStatusSuccess(r);
assertNull(r.getArtifactsDir().list());
}
}
}

0 comments on commit d487888

Please sign in to comment.