mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-06 08:36:01 +00:00
[FIXED HUDSON-4925] optional filtering by view for the build executors status and build queue
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@24184 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
f15fa2066b
commit
2deb95e6a3
6 files changed
+156
-19
No files matched your search
@@ -23,13 +23,13 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import static hudson.model.Hudson.checkGoodName;
|
||||
import hudson.DescriptorExtensionList;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import hudson.DescriptorExtensionList;
|
||||
import hudson.widgets.Widget;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
import static hudson.model.Hudson.checkGoodName;
|
||||
import hudson.model.Node.Mode;
|
||||
import hudson.scm.ChangeLogSet.Entry;
|
||||
import hudson.search.CollectionSearchIndex;
|
||||
import hudson.search.SearchIndexBuilder;
|
||||
@@ -39,25 +39,28 @@ import hudson.security.Permission;
|
||||
import hudson.security.PermissionGroup;
|
||||
import hudson.util.DescriptorList;
|
||||
import hudson.util.RunList;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
import hudson.widgets.Widget;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.text.ParseException;
|
||||
import org.kohsuke.stapler.HttpRedirect;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
|
||||
/**
|
||||
* Encapsulates the rendering of the list of {@link TopLevelItem}s
|
||||
@@ -96,6 +99,16 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
* Message displayed in the view page.
|
||||
*/
|
||||
protected String description;
|
||||
|
||||
/**
|
||||
* If true, only show relevant executors
|
||||
*/
|
||||
protected boolean filterExecutors;
|
||||
|
||||
/**
|
||||
* If true, only show relevant queue items
|
||||
*/
|
||||
protected boolean filterQueue;
|
||||
|
||||
protected View(String name) {
|
||||
this.name = name;
|
||||
@@ -187,8 +200,22 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
public boolean isEditable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If true, only show relevant executors
|
||||
*/
|
||||
public boolean isFilterExecutors() {
|
||||
return filterExecutors;
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, only show relevant queue items
|
||||
*/
|
||||
public boolean isFilterQueue() {
|
||||
return filterQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Widget}s registered on this object.
|
||||
*
|
||||
* <p>
|
||||
@@ -204,6 +231,56 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
public boolean isDefault() {
|
||||
return Hudson.getInstance().getPrimaryView()==this;
|
||||
}
|
||||
|
||||
public List<Computer> getComputers() {
|
||||
Computer[] computers = Hudson.getInstance().getComputers();
|
||||
|
||||
if (!isFilterExecutors()) {
|
||||
return Arrays.asList(computers);
|
||||
}
|
||||
|
||||
List<Computer> result = new ArrayList<Computer>();
|
||||
|
||||
boolean roam = false;
|
||||
HashSet<Label> labels = new HashSet<Label>();
|
||||
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 (c != null) {
|
||||
if (roam && n.getMode() == Mode.NORMAL || !Collections.disjoint(n.getAssignedLabels(), labels)) {
|
||||
result.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Queue.Item> getQueueItems() {
|
||||
if (!isFilterQueue()) {
|
||||
return Arrays.asList(Hudson.getInstance().getQueue().getItems());
|
||||
}
|
||||
|
||||
Collection<TopLevelItem> items = getItems();
|
||||
List<Queue.Item> result = new ArrayList<Queue.Item>();
|
||||
for (Queue.Item qi: Hudson.getInstance().getQueue().getItems()) {
|
||||
if (items.contains(qi.task)) {
|
||||
result.add(qi);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path relative to the context root.
|
||||
@@ -484,6 +561,8 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
submit(req);
|
||||
|
||||
description = Util.nullify(req.getParameter("description"));
|
||||
filterExecutors = req.getParameter("filterExecutors") != null;
|
||||
filterQueue = req.getParameter("filterQueue") != null;
|
||||
|
||||
try {
|
||||
rename(req.getParameter("name"));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,6 +27,6 @@ THE SOFTWARE.
|
||||
-->
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
|
||||
<l:ajax>
|
||||
<t:executors />
|
||||
<t:executors computers="${it.computers}"/>
|
||||
</l:ajax>
|
||||
</j:jelly>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -40,6 +40,12 @@ THE SOFTWARE.
|
||||
<f:entry title="${%Description}" help="/help/view-config/description.html">
|
||||
<f:textarea name="description" field="description" />
|
||||
</f:entry>
|
||||
<f:entry title="${%Filter build queue}" help="/help/view-config/filter-queue.html">
|
||||
<f:checkbox name="filterQueue" field="filterQueue"/>
|
||||
</f:entry>
|
||||
<f:entry title="${%Filter build executors}" help="/help/view-config/filter-executors.html">
|
||||
<f:checkbox name="filterExecutors" field="filterExecutors"/>
|
||||
</f:entry>
|
||||
|
||||
<!-- subtypes can put entries here. -->
|
||||
<st:include page="configure-entries.jelly" optional="true" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer, id:cactusman
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer, id:cactusman, Tom Huybrechts
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -58,8 +58,8 @@ THE SOFTWARE.
|
||||
|
||||
<t:actions />
|
||||
</l:tasks>
|
||||
<t:queue items="${app.queue.items}" />
|
||||
<t:executors />
|
||||
<t:queue items="${it.queueItems}" />
|
||||
<t:executors computers="${it.computers}" />
|
||||
<j:forEach var="w" items="${it.widgets}">
|
||||
<st:include it="${w}" page="index.jelly" />
|
||||
</j:forEach>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Tom Huybrechts
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<div>
|
||||
If checked, only those build executors will be shown that could execute the jobs in this view.
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc., Tom Huybrechts
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
<div>
|
||||
If checked, only jobs in this view will be shown in the queue.
|
||||
</div>
|
||||
Reference in new issue
Block a user