Navigation Menu

Skip to content

Commit

Permalink
[FIXED JENKINS-19179] - Prevent the disabling of Matrix Configurations
Browse files Browse the repository at this point in the history
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 fe786b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/hudson/matrix/MatrixConfiguration.java
Expand Up @@ -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}.
Expand Down Expand Up @@ -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}.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/hudson/matrix/Messages.properties
Expand Up @@ -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

Expand Down

0 comments on commit fe786b4

Please sign in to comment.