Skip to content

Commit

Permalink
Merge pull request #84 from jenkinsci/jenkins-39026-follow-up
Browse files Browse the repository at this point in the history
[JENKINS-39026 Follow-up] Add ViewBranchFilter implementations for PRs and GitHub branches
  • Loading branch information
stephenc committed Oct 18, 2016
2 parents 4fa015f + 7872bf2 commit 03f37a2
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Expand Up @@ -5,6 +5,7 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.12</version>
<relativePath/>
</parent>
<artifactId>github-branch-source</artifactId>
<version>1.11-SNAPSHOT</version>
Expand Down Expand Up @@ -36,6 +37,12 @@
<artifactId>scm-api</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
<version>1.12-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
Expand Down
@@ -0,0 +1,70 @@
/*
* The MIT License
*
* Copyright 2016 CloudBees, Inc.
*
* 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.
*/

package org.jenkinsci.plugins.github_branch_source;

import hudson.Extension;
import hudson.model.Descriptor;
import hudson.views.ViewJobFilter;
import jenkins.branch.Branch;
import jenkins.branch.SimpleViewBranchFilter;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* A {@link ViewJobFilter} that matches {@link PullRequestSCMHead} based branches.
*
* @since FIXME
*/
public class GitHubBranchFilter extends SimpleViewBranchFilter {
/**
* Our constructor.
*/
@DataBoundConstructor
public GitHubBranchFilter() {
}

/**
* {@inheritDoc}
*/
@Override
public boolean isIncluded(Branch branch) {
return branch.getHead() instanceof BranchSCMHead;
}

/**
* Our descriptor.
*/
@Extension(optional = true)
public static class DescriptorImpl extends Descriptor<ViewJobFilter> {

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return Messages.GitHubBranchFilter_DisplayName();
}
}

}
@@ -0,0 +1,70 @@
/*
* The MIT License
*
* Copyright 2016 CloudBees, Inc.
*
* 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.
*/

package org.jenkinsci.plugins.github_branch_source;

import hudson.Extension;
import hudson.model.Descriptor;
import hudson.views.ViewJobFilter;
import jenkins.branch.Branch;
import jenkins.branch.SimpleViewBranchFilter;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* A {@link ViewJobFilter} that matches {@link PullRequestSCMHead} based branches.
*
* @since FIXME
*/
public class GitHubPullRequestFilter extends SimpleViewBranchFilter {
/**
* Our constructor.
*/
@DataBoundConstructor
public GitHubPullRequestFilter() {
}

/**
* {@inheritDoc}
*/
@Override
public boolean isIncluded(Branch branch) {
return branch.getHead() instanceof PullRequestSCMHead;
}

/**
* Our descriptor.
*/
@Extension(optional = true)
public static class DescriptorImpl extends Descriptor<ViewJobFilter> {

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return Messages.GitHubPullRequestFilter_DisplayName();
}
}

}
@@ -1,5 +1,7 @@
BranchSCMHead.Pronoun=Branch

GitHubBranchFilter.DisplayName=GitHub Branch Jobs Only

GitHubBuildStatusNotification.CommitStatus.Good=This commit looks good
GitHubBuildStatusNotification.CommitStatus.Unstable=This commit has test failures
GitHubBuildStatusNotification.CommitStatus.Failure=This commit cannot be built
Expand All @@ -8,6 +10,8 @@ GitHubBuildStatusNotification.CommitStatus.Pending=This commit is being built
GitHubBuildStatusNotification.CommitStatus.Queued=This commit is scheduled to be built
GitHubBuildStatusNotification.CommitStatusSet=GitHub has been notified of this commit\u2019s build result

GitHubPullRequestFilter.DisplayName=GitHub Pull Request Jobs Only

GitHubSCMNavigator.DisplayName=GitHub Organization
GitHubSCMNavigator.Description=Scans a GitHub organization (or user account) for all repositories matching some defined markers.
GitHubSCMNavigator.Pronoun=Organization
Expand Down

0 comments on commit 03f37a2

Please sign in to comment.