();
+ r.add(getAssignedLabel());
+ for (MatrixConfiguration c : getActiveConfigurations())
+ r.add(c.getAssignedLabel());
+ return super.getRelevantLabels();
+ }
+
public void setSorter(MatrixConfigurationSorter sorter) throws IOException {
this.sorter = sorter;
save();
diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java
index ac6e28b849acb619069ab5fd2c91216cf4ad328a..4b4871ded9b9bf43dc6d4529dbd046623ab69efa 100644
--- a/core/src/main/java/hudson/model/AbstractProject.java
+++ b/core/src/main/java/hudson/model/AbstractProject.java
@@ -314,6 +314,21 @@ public abstract class AbstractProject,R extends A
return Jenkins.getInstance().getLabel(assignedNode);
}
+ /**
+ * Set of labels relevant to this job.
+ *
+ * This method is used to determine what slaves are relevant to jobs, for example by {@link View}s.
+ * It does not affect the scheduling. This information is informational and the best-effort basis.
+ *
+ * @since 1.456
+ * @return
+ * Minimally it should contain {@link #getAssignedLabel()}. The set can contain null element
+ * to correspond to the null return value from {@link #getAssignedLabel()}.
+ */
+ public Set getRelevantLabels() {
+ return Collections.singleton(getAssignedLabel());
+ }
+
/**
* Gets the textual representation of the assigned label as it was entered by the user.
*/
diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java
index 0cf1a1d2bb42c683e3d9417a35e304c2daf05a58..230a76edb1237597b1121ce53f4dbdf4dcc43a6a 100644
--- a/core/src/main/java/hudson/model/View.java
+++ b/core/src/main/java/hudson/model/View.java
@@ -365,53 +365,52 @@ public abstract class View extends AbstractModelObject implements AccessControll
}
public List getComputers() {
- Computer[] computers = Jenkins.getInstance().getComputers();
-
- if (!isFilterExecutors()) {
- return Arrays.asList(computers);
- }
-
- List result = new ArrayList();
-
- boolean roam = false;
- HashSet labels = new HashSet();
- for (Item item: getItems()) {
- if (item instanceof AbstractProject,?>) {
- AbstractProject,?> p = (AbstractProject, ?>) item;
- Label l = p.getAssignedLabel();
- if (l != null) {
- labels.add(l);
- } else {
- roam = true;
- }
- }
- }
-
- for (Computer c: computers) {
- Node n = c.getNode();
- if (n != null) {
- if (roam && n.getMode() == Mode.NORMAL || !Collections.disjoint(n.getAssignedLabels(), labels)) {
- result.add(c);
- }
- }
- }
-
- return result;
+ Computer[] computers = Jenkins.getInstance().getComputers();
+
+ if (!isFilterExecutors()) {
+ return Arrays.asList(computers);
+ }
+
+ List result = new ArrayList();
+
+ HashSet labels = new HashSet();
+ for (Item item : getItems()) {
+ if (item instanceof AbstractProject, ?>) {
+ labels.addAll(((AbstractProject, ?>) item).getRelevantLabels());
+ }
+ }
+
+ for (Computer c : computers) {
+ Node n = c.getNode();
+ if (n != null) {
+ if (labels.contains(null) && n.getMode() == Mode.NORMAL || !Collections.disjoint(n.getAssignedLabels(), labels)) {
+ result.add(c);
+ }
+ }
+ }
+
+ return result;
}
public List getQueueItems() {
- if (!isFilterQueue()) {
- return Arrays.asList(Jenkins.getInstance().getQueue().getItems());
- }
-
- Collection items = getItems();
- List result = new ArrayList();
- for (Queue.Item qi: Jenkins.getInstance().getQueue().getItems()) {
- if (items.contains(qi.task)) {
- result.add(qi);
- }
- }
- return result;
+ if (!isFilterQueue()) {
+ return Arrays.asList(Jenkins.getInstance().getQueue().getItems());
+ }
+
+ Collection items = getItems();
+ List result = new ArrayList();
+ for (Queue.Item qi : Jenkins.getInstance().getQueue().getItems()) {
+ if (items.contains(qi.task)) {
+ result.add(qi);
+ } else
+ if (qi.task instanceof AbstractProject, ?>) {
+ AbstractProject,?> project = (AbstractProject, ?>) qi.task;
+ if (items.contains(project.getRootProject())) {
+ result.add(qi);
+ }
+ }
+ }
+ return result;
}
/**