Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Foster2014-01-10 17:43:37 -0500
committerBob Foster2014-01-10 17:43:37 -0500
commit2d6249b175ec83b42b0f6cce21e05f1d0c642d73 (patch)
tree45f8cefc0b7629029a6a8eaffa5bfe53ae03675d
parentedd2c7e1bfaaa21b1c23c68cf1f0aa13ac87bd09 (diff)
downloadorg.eclipse.hudson.core-2d6249b175ec83b42b0f6cce21e05f1d0c642d73.tar.gz
org.eclipse.hudson.core-2d6249b175ec83b42b0f6cce21e05f1d0c642d73.tar.xz
org.eclipse.hudson.core-2d6249b175ec83b42b0f6cce21e05f1d0c642d73.zip
Fix NPE in AbstractProject when build; add BuildBlocker extension point
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java10
-rw-r--r--hudson-core/src/main/java/hudson/model/BuildBlocker.java32
2 files changed, 41 insertions, 1 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 5051d03a..5e26901c 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -22,6 +22,7 @@ package hudson.model;
import hudson.AbortException;
import hudson.CopyOnWrite;
+import hudson.ExtensionList;
import hudson.FeedAdapter;
import hudson.FilePath;
import hudson.Functions;
@@ -1423,6 +1424,13 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
return new BecauseOfUpstreamBuildInProgress(bup);
}
}
+ ExtensionList<BuildBlocker> blockers = Hudson.getInstance().getExtensionList(BuildBlocker.class);
+ for (BuildBlocker blocker : blockers) {
+ CauseOfBlockage cause = blocker.getCauseOfBlockage(this);
+ if (cause != null) {
+ return cause;
+ }
+ }
return null;
}
@@ -1943,8 +1951,8 @@ public abstract class AbstractProject<P extends AbstractProject<P, R>, R extends
// if a build is parameterized, let that take over
ParametersDefinitionProperty pp = getProperty(ParametersDefinitionProperty.class);
- pp.setOwner(this);
if (pp != null) {
+ pp.setOwner(this);
pp._doBuild(req, rsp);
return;
}
diff --git a/hudson-core/src/main/java/hudson/model/BuildBlocker.java b/hudson-core/src/main/java/hudson/model/BuildBlocker.java
new file mode 100644
index 00000000..7a0ecc0b
--- /dev/null
+++ b/hudson-core/src/main/java/hudson/model/BuildBlocker.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014 Hudson.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Hudson - initial API and implementation and/or initial documentation
+ */
+
+package hudson.model;
+
+import hudson.ExtensionPoint;
+import hudson.model.queue.CauseOfBlockage;
+
+/**
+ * Extension point that allows plugins to prevent projects from building
+ * based on external considerations, e.g., site-specific quota exceeded,
+ * or plugin configuration.
+ *
+ * @author Bob Foster
+ */
+public abstract class BuildBlocker implements ExtensionPoint {
+
+ /**
+ * If project is to be blocked from building, return CauseOfBlockage.
+ * @param project to be checked
+ * @return CauseOfBlockage or null if not blocked
+ */
+ abstract public CauseOfBlockage getCauseOfBlockage(AbstractProject project);
+}

Back to the top