Skip to content
Permalink
Browse files
[FIXED JENKINS-19179] - Prevent the disabling of Matrix Configurations
This change blocks calls, which try to disable matrix configurations.
MatrixConfiguration::isDisabled() always returns the parent's value.

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information
oleg-nenashev committed Aug 5, 2014
1 parent f6656ca commit fe786b4b47e8137f538e451a3ed888ace5e85780
Showing with 24 additions and 0 deletions.
  1. +23 −0 src/main/java/hudson/matrix/MatrixConfiguration.java
  2. +1 −0 src/main/resources/hudson/matrix/Messages.properties
@@ -49,18 +49,22 @@
import hudson.model.SCMedItem;
import hudson.model.Queue.NonBlockingTask;
import hudson.model.Cause.LegacyCodeCause;
import hudson.model.Failure;
import hudson.scm.SCM;
import jenkins.scm.SCMCheckoutStrategy;
import hudson.tasks.BuildWrapper;
import hudson.tasks.Builder;
import hudson.tasks.LogRotator;
import hudson.tasks.Publisher;
import hudson.util.HttpResponses;

import java.io.IOException;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import org.kohsuke.stapler.HttpResponse;

/**
* One configuration of {@link MatrixProject}.
@@ -105,6 +109,25 @@ public EnvVars getEnvironment(Node node, TaskListener listener) throws IOExcepti
return env;
}

@Override
public final boolean isDisabled() {
// Matrix configurations cannot be disabled independently from the master
return getParent().isDisabled();
}

@Override
public final void makeDisabled(boolean b) throws IOException {
if (/**disable*/ b) {
throw new Error("Matrix configurations cannot be disabled separately. Disable the parent project instead");
}
super.makeDisabled(b);
}

@Override
public final HttpResponse doDisable() throws IOException, ServletException {
return HttpResponses.errorWithoutStack(405, Messages.MatrixConfiguration_DisableNotAllowed());
}

@Override
protected void updateTransientActions(){
// This method is exactly the same as in {@link #AbstractProject}.
@@ -32,6 +32,7 @@ MatrixBuild.Interrupting=Interrupting {0}
MatrixBuild.Completed={0} completed with result {1}

MatrixConfiguration.Pronoun=Configuration
MatrixConfiguration.DisableNotAllowed=Matrix configurations cannot be disabled separately. Disable the parent project instead

MatrixRun.KeptBecauseOfParent=Kept because {0} is kept

0 comments on commit fe786b4

Please sign in to comment.