Skip to content
Permalink
Browse files

[FIXED JENKINS-12036] conditional steps don't appear in matrix (multi…

…-config) projects
  • Loading branch information
imod committed Dec 31, 2011
1 parent 029eeea commit 8ef5a4c965b77ce0bbe5595ce15f7c2eee750558
@@ -26,9 +26,6 @@
import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.Launcher;
import hudson.matrix.MatrixAggregatable;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
@@ -47,8 +44,6 @@

import org.jenkins_ci.plugins.run_condition.RunCondition;
import org.jenkins_ci.plugins.run_condition.BuildStepRunner;
import org.jenkinsci.plugins.conditionalbuildstep.matrix.DummyMatrixAggregator;
import org.jenkinsci.plugins.conditionalbuildstep.matrix.MatrixAggregatorChain;
import org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder;
import org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder.SingleConditionalBuilderDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -59,7 +54,7 @@
*
* @author Dominik Bartholdi (imod)
*/
public class ConditionalBuilder extends Builder implements MatrixAggregatable {
public class ConditionalBuilder extends Builder {
private static Logger log = Logger.getLogger(ConditionalBuilder.class.getName());

// retaining backward compatibility
@@ -102,26 +97,6 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
return runner.perform(runCondition, new BuilderChain(conditionalbuilders), build, launcher, listener);
}

/**
* @see MatrixAggregatable#createAggregator(MatrixBuild, Launcher, BuildListener)
*/
public MatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) {
// FIXME get the runCondition to tell whether we have to run it or not
if (true) {
return new DummyMatrixAggregator(build, launcher, listener);
}
List<MatrixAggregator> aggregators = new ArrayList<MatrixAggregator>();
for (BuildStep buildStep : conditionalbuilders) {
if (buildStep instanceof MatrixAggregatable) {
final MatrixAggregator aggregator = ((MatrixAggregatable) buildStep).createAggregator(build, launcher, listener);
if (aggregator != null) {
aggregators.add(aggregator);
}
}
}
return new MatrixAggregatorChain(aggregators, build, launcher, listener);
}

public Object readResolve() {
if (condition != null) {
// retaining backward compatibility
@@ -139,6 +114,8 @@ public DescriptorImpl getDescriptor() {
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public boolean isApplicable(final Class<? extends AbstractProject> aClass) {
// No need for aggregation for matrix build with MatrixAggregatable
// this is only supported for: {@link Publisher}, {@link JobProperty}, {@link BuildWrapper}
return !SingleConditionalBuilder.PROMOTION_JOB_TYPE.equals(aClass.getCanonicalName());
}

@@ -27,9 +27,6 @@
import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.Launcher;
import hudson.matrix.MatrixAggregatable;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
@@ -52,7 +49,6 @@
import org.jenkinsci.plugins.conditionalbuildstep.Messages;
import org.jenkinsci.plugins.conditionalbuildstep.lister.BuilderDescriptorLister;
import org.jenkinsci.plugins.conditionalbuildstep.lister.DefaultBuilderDescriptorLister;
import org.jenkinsci.plugins.conditionalbuildstep.matrix.DummyMatrixAggregator;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
@@ -62,7 +58,7 @@
* @author Anthony Robinson
* @author Dominik Bartholdi (imod)
*/
public class SingleConditionalBuilder extends Builder implements MatrixAggregatable {
public class SingleConditionalBuilder extends Builder {

public static final String PROMOTION_JOB_TYPE = "hudson.plugins.promoted_builds.PromotionProcess";

@@ -108,19 +104,6 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
return runner.perform(condition, buildStep, build, launcher, listener);
}

public MatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) {

// FIXME get the runCondition to tell whether we have to run it or not
if (true) {
return new DummyMatrixAggregator(build, launcher, listener);
}

if (buildStep instanceof MatrixAggregatable) {
return ((MatrixAggregatable) buildStep).createAggregator(build, launcher, listener);
}
return new DummyMatrixAggregator(build, launcher, listener);
}

@Extension(ordinal = Integer.MAX_VALUE - 500)
public static class SingleConditionalBuilderDescriptor extends BuildStepDescriptor<Builder> {

@@ -160,6 +143,8 @@ public String getDisplayName() {
}

public boolean isApplicable(final Class<? extends AbstractProject> aClass) {
// No need for aggregation for matrix build with MatrixAggregatable
// this is only supported for: {@link Publisher}, {@link JobProperty}, {@link BuildWrapper}
return !PROMOTION_JOB_TYPE.equals(aClass.getCanonicalName());
}

0 comments on commit 8ef5a4c

Please sign in to comment.
You can’t perform that action at this time.