From 2d49f01d210be0869e0861cff4158847d98db14e Mon Sep 17 00:00:00 2001 From: Sergey Zhemzhitsky Date: Tue, 28 Jun 2016 15:30:11 +0300 Subject: [PATCH 1/2] option to skip pullrequests --- .../plugins/bitbucket/BitbucketSCMSource.java | 20 +++++++++++++++++-- .../BitbucketSCMSource/config-detail.jelly | 3 +++ .../help-skipPullRequests.jelly | 8 ++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/help-skipPullRequests.jelly diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java index c709cdb13..9c760cb19 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java @@ -118,6 +118,11 @@ public class BitbucketSCMSource extends SCMSource { */ private String excludes = ""; + /** + * Whether to skip discovered pull requests. + */ + private boolean skipPullRequests; + /** * If true, a webhook will be auto-registered in the repository managed by this source. */ @@ -194,6 +199,15 @@ public void setExcludes(@NonNull String excludes) { this.excludes = excludes; } + public boolean isSkipPullRequests() { + return skipPullRequests; + } + + @DataBoundSetter + public void setSkipPullRequests(boolean skipPullRequests) { + this.skipPullRequests = skipPullRequests; + } + public String getRepoOwner() { return repoOwner; } @@ -277,8 +291,10 @@ protected void retrieve(SCMHeadObserver observer, final TaskListener listener) t // Search branches retrieveBranches(observer, listener); - // Search pull requests - retrievePullRequests(observer, listener); + if (!isSkipPullRequests()) { + // Search pull requests + retrievePullRequests(observer, listener); + } } private void retrievePullRequests(SCMHeadObserver observer, final TaskListener listener) throws IOException { diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/config-detail.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/config-detail.jelly index c1166e092..259b95f9d 100644 --- a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/config-detail.jelly +++ b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/config-detail.jelly @@ -20,6 +20,9 @@ + + + diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/help-skipPullRequests.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/help-skipPullRequests.jelly new file mode 100644 index 000000000..f26f3b152 --- /dev/null +++ b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource/help-skipPullRequests.jelly @@ -0,0 +1,8 @@ + + + +
+ Whether or not to create jobs for discovered pull requests. +
+
+
\ No newline at end of file From 8c10c4a518e868d8bb7dddc7c499332e1f249dab Mon Sep 17 00:00:00 2001 From: Mohit Dharamshi Date: Tue, 22 Nov 2016 18:38:17 +0530 Subject: [PATCH 2/2] Skip Pull requests for teams Extends the skip pull request feature for BitBucket team projects. --- .../plugins/bitbucket/BitbucketSCMNavigator.java | 11 +++++++++++ .../bitbucket/BitbucketSCMNavigator/config.jelly | 3 +++ .../BitbucketSCMNavigator/help-skipPullRequests.jelly | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/help-skipPullRequests.jelly diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java index 251e19d5b..39da810ba 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java @@ -63,12 +63,17 @@ public class BitbucketSCMNavigator extends SCMNavigator { private boolean autoRegisterHooks = false; private String bitbucketServerUrl; private int sshPort = -1; + private boolean skipPullRequests; /** * Bitbucket API client connector. */ private transient BitbucketApiConnector bitbucketConnector; + public boolean isSkipPullRequests() { + return skipPullRequests; + } + @DataBoundConstructor public BitbucketSCMNavigator(String repoOwner, String credentialsId, String checkoutCredentialsId) { this.repoOwner = repoOwner; @@ -76,6 +81,11 @@ public BitbucketSCMNavigator(String repoOwner, String credentialsId, String chec this.checkoutCredentialsId = checkoutCredentialsId; } + @DataBoundSetter + public void setSkipPullRequests(boolean skipPullRequests) { + this.skipPullRequests = skipPullRequests; + } + @DataBoundSetter public void setPattern(String pattern) { Pattern.compile(pattern); @@ -194,6 +204,7 @@ private void add(TaskListener listener, SCMSourceObserver observer, BitbucketRep scmSource.setAutoRegisterHook(isAutoRegisterHooks()); scmSource.setBitbucketServerUrl(bitbucketServerUrl); scmSource.setSshPort(sshPort); + scmSource.setSkipPullRequests(isSkipPullRequests()); projectObserver.addSource(scmSource); projectObserver.complete(); } diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/config.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/config.jelly index b0a2caf96..a38f6ff42 100644 --- a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/config.jelly +++ b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/config.jelly @@ -17,6 +17,9 @@ + + + diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/help-skipPullRequests.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/help-skipPullRequests.jelly new file mode 100644 index 000000000..f26f3b152 --- /dev/null +++ b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator/help-skipPullRequests.jelly @@ -0,0 +1,8 @@ + + + +
+ Whether or not to create jobs for discovered pull requests. +
+
+
\ No newline at end of file