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/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/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 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