Diff
Modified: trunk/hudson/plugins/view-job-filters/pom.xml (40564 => 40565)
--- trunk/hudson/plugins/view-job-filters/pom.xml 2012-05-14 16:04:53 UTC (rev 40564)
+++ trunk/hudson/plugins/view-job-filters/pom.xml 2012-05-15 20:00:45 UTC (rev 40565)
@@ -50,6 +50,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <!-- Other versions not found, this project could not build -->
+ <version>1.3.0.201202151440-r</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>email-ext</artifactId>
<version>2.7</version>
@@ -90,7 +97,6 @@
</repository>
</distributionManagement>
-
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Modified: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/OtherViewsFilter.java (40564 => 40565)
--- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/OtherViewsFilter.java 2012-05-14 16:04:53 UTC (rev 40564)
+++ trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/OtherViewsFilter.java 2012-05-15 20:00:45 UTC (rev 40565)
@@ -145,6 +145,10 @@
}
public static List<View> getAllViews() {
+ // TODO this line seems to be what I would have to fix for JENKINS 21738
+ // the problem here is that I don't want to upgrade to a newer version of Jenkins, because that would make me maintain for Hudson
+ // and there is no fix for this in the 1.395 API.
+ // also, it appears that this problem will most likely only occur with the sectioned-view plugin
Collection<View> baseViews = Hudson.getInstance().getViews();
// build comprehensive list
Added: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java (0 => 40565)
--- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java (rev 0)
+++ trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java 2012-05-15 20:00:45 UTC (rev 40565)
@@ -0,0 +1,126 @@
+package hudson.views;
+
+import hudson.Extension;
+import hudson.model.AbstractProject;
+import hudson.model.Descriptor;
+import hudson.model.TopLevelItem;
+import hudson.model.View;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.kohsuke.stapler.DataBoundConstructor;
+
+public class UpstreamDownstreamJobsFilter extends ViewJobFilter {
+
+ private boolean includeDownstream;
+ private boolean includeUpstream;
+ private boolean recursive;
+ private boolean excludeOriginals;
+
+ @DataBoundConstructor
+ public UpstreamDownstreamJobsFilter(boolean includeDownstream, boolean includeUpstream,
+ boolean recursive, boolean excludeOriginals) {
+ this.includeDownstream = includeDownstream;
+ this.excludeOriginals = excludeOriginals;
+ this.includeUpstream = includeUpstream;
+ this.recursive = recursive;
+ }
+
+ @Override
+ public List<TopLevelItem> filter(List<TopLevelItem> added, List<TopLevelItem> all, View filteringView) {
+ Set<TopLevelItem> filtered = new HashSet<TopLevelItem>();
+
+ for (TopLevelItem next: added) {
+ if (includeUpstream) {
+ addUpstream(next, filtered, all);
+ }
+ if (includeDownstream) {
+ addDownstream(next, filtered, all);
+ }
+ }
+
+ List<TopLevelItem> sorted = new ArrayList<TopLevelItem>(all);
+
+ // ensure all the previously added items are included
+ if (!excludeOriginals) {
+ filtered.addAll(added);
+ }
+
+ sorted.retainAll(filtered);
+
+ return sorted;
+ }
+
+ public void addUpstream(TopLevelItem current, Set<TopLevelItem> filtered, List<TopLevelItem> all) {
+ for (TopLevelItem next: all) {
+ if (filtered.contains(next)) {
+ continue;
+ }
+ boolean isFirstUpstreamFromSecond = isFirstUpstreamFromSecond(next, current);
+ if (isFirstUpstreamFromSecond) {
+ filtered.add(next);
+ if (recursive) {
+ addUpstream(next, filtered, all);
+ }
+ }
+ }
+ }
+ public void addDownstream(TopLevelItem current, Set<TopLevelItem> filtered, List<TopLevelItem> all) {
+ for (TopLevelItem next: all) {
+ if (filtered.contains(next)) {
+ continue;
+ }
+ boolean isFirstUpstreamFromSecond = isFirstUpstreamFromSecond(current, next);
+ if (isFirstUpstreamFromSecond) {
+ filtered.add(next);
+ if (recursive) {
+ addDownstream(next, filtered, all);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean isFirstUpstreamFromSecond(TopLevelItem first, TopLevelItem second) {
+ if (second instanceof AbstractProject) {
+ AbstractProject secondProject = (AbstractProject) second;
+ List<AbstractProject> upstream = secondProject.getBuildTriggerUpstreamProjects();
+ return upstream.contains(first);
+ }
+ return false;
+ }
+
+
+ @Extension
+ public static class DescriptorImpl extends Descriptor<ViewJobFilter> {
+ @Override
+ public String getDisplayName() {
+ return "Upstream/Downstream Jobs Filter";
+ }
+ @Override
+ public String getHelpFile() {
+ return "/plugin/view-job-filters/upstream-downstream-help.html";
+ }
+ }
+
+
+ public boolean isIncludeDownstream() {
+ return includeDownstream;
+ }
+
+ public boolean isIncludeUpstream() {
+ return includeUpstream;
+ }
+
+ public boolean isRecursive() {
+ return recursive;
+ }
+
+ public boolean isExcludeOriginals() {
+ return excludeOriginals;
+ }
+
+}
Property changes on: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UserRelevanceFilter.java (40564 => 40565)
--- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UserRelevanceFilter.java 2012-05-14 16:04:53 UTC (rev 40564)
+++ trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UserRelevanceFilter.java 2012-05-15 20:00:45 UTC (rev 40565)
@@ -139,6 +139,9 @@
public boolean matchesEmail(TopLevelItem item) {
User user = getUser();
+ if (user == null) {
+ return false;
+ }
if (matchUserFullName) {
String userName = normalize(user.getFullName());
if (matchesEmail(item, userName)) {
Added: trunk/hudson/plugins/view-job-filters/src/main/resources/hudson/views/UpstreamDownstreamJobsFilter/config.jelly (0 => 40565)
--- trunk/hudson/plugins/view-job-filters/src/main/resources/hudson/views/UpstreamDownstreamJobsFilter/config.jelly (rev 0)
+++ trunk/hudson/plugins/view-job-filters/src/main/resources/hudson/views/UpstreamDownstreamJobsFilter/config.jelly 2012-05-15 20:00:45 UTC (rev 40565)
@@ -0,0 +1,12 @@
+<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
+ xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
+ xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
+
+ <f:entry>
+ <f:checkbox name="includeDownstream" field="includeDownstream" /> ${%Include downstream jobs} <br/>
+ <f:checkbox name="includeUpstream" field="includeUpstream" /> ${%Include upstream jobs} <br/>
+ <f:checkbox name="recursive" field="recursive" /> ${%Include upstream/downstream jobs recursively} <br/>
+ <f:checkbox name="excludeOriginals" field="excludeOriginals" /> ${%Do not show source jobs}
+ </f:entry>
+
+</j:jelly>
\ No newline at end of file
Added: trunk/hudson/plugins/view-job-filters/src/main/webapp/upstream-downstream-help.html (0 => 40565)
--- trunk/hudson/plugins/view-job-filters/src/main/webapp/upstream-downstream-help.html (rev 0)
+++ trunk/hudson/plugins/view-job-filters/src/main/webapp/upstream-downstream-help.html 2012-05-15 20:00:45 UTC (rev 40565)
@@ -0,0 +1,11 @@
+<div>
+This filter allows you to create a view consisting of jobs that are related through the concept of Upstream/Downstream (also called "Build after other projects are built" and "Build other projects").
+<br/>
+The options provided allow you to choose exactly which types of related jobs to show.
+<br/><br/>
+<u>Note</u> that filters are chained together, so using this filter builds off of the jobs included by previous filters. Remember that
+<ul>
+ <li>This filter will not include any jobs if there are no jobs already selected</li>
+ <li>This filter (like most other filters) is capable of removing jobs that were already selected</li>
+</ul>
+</div>
\ No newline at end of file
Property changes on: trunk/hudson/plugins/view-job-filters/src/main/webapp/upstream-downstream-help.html
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/UserRelevanceFilterTest.java (40564 => 40565)
--- trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/UserRelevanceFilterTest.java 2012-05-14 16:04:53 UTC (rev 40564)
+++ trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/UserRelevanceFilterTest.java 2012-05-15 20:00:45 UTC (rev 40565)
@@ -89,5 +89,16 @@
String normalized = filter.normalize(input);
assertEquals(output, normalized);
}
+ public void testMatchesEmail_JENKINS_13781() {
+ UserRelevanceFilter filter = new UserRelevanceFilter(
+ true, true, true, true, true,
+ true, true, true,
+ BuildCountType.AtLeastOne.toString(), 2, AmountType.Builds.toString(),
+ AbstractIncludeExcludeJobFilter.IncludeExcludeType.includeMatched.toString()
+ );
+ // FIXED: would throw null-pointer
+ boolean matched = filter.matchesEmail(null);
+ assertFalse(matched);
+ }
}