Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

/**
* SCM source implementation for Bitbucket.
*
*
* It provides a way to discover/retrieve branches and pull requests through the Bitbuclet REST API
* which is much faster than the plain Git SCM source implementation.
*/
Expand Down Expand Up @@ -286,7 +286,7 @@ private void retrievePullRequests(SCMHeadObserver observer, final TaskListener l
listener.getLogger().println("Looking up " + fullName + " for pull requests");

final BitbucketApi bitbucket = getBitbucketConnector().create(repoOwner, repository, getScanCredentials());
if (bitbucket.isPrivate()) {
if (bitbucket.isPrivate() || bitbucketServerUrl != "https://bitbucket.org") {
List<? extends BitbucketPullRequest> pulls = bitbucket.getPullRequests();
for (final BitbucketPullRequest pull : pulls) {
listener.getLogger().println(
Expand Down Expand Up @@ -329,9 +329,15 @@ private void retrieveBranches(@NonNull final SCMHeadObserver observer, @NonNull
}

private void observe(SCMHeadObserver observer, final TaskListener listener,
final String owner, final String repositoryName,
final String owner, final String repositoryName,
final String branchName, final String hash, BitbucketPullRequest pr) throws IOException {
if (isExcluded(branchName)) {

String branchNameForExclusionTest = branchName;
if (pr != null) {
branchNameForExclusionTest = String.format("PR-%s %s", pr.getId(), pr.getSource().getBranch().getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is related to the fix explained in the description, but useful I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, you are right @amuniz, I didn't realize future commits to my fork updated the PR. This is a fix to allow "PR-*" branch matching to work (https://issues.jenkins-ci.org/browse/JENKINS-36890). Would you like me to file this as a separate PR?

}

if (isExcluded(branchNameForExclusionTest)) {
return;
}
final BitbucketApi bitbucket = getBitbucketConnector().create(owner, repositoryName, getScanCredentials());
Expand Down Expand Up @@ -455,7 +461,7 @@ public String getRemoteName() {

/**
* Returns true if the branchName isn't matched by includes or is matched by excludes.
*
*
* @param branchName
* @return true if branchName is excluded or is not included
*/
Expand All @@ -465,9 +471,9 @@ private boolean isExcluded(String branchName) {
}

/**
* Returns the pattern corresponding to the branches containing wildcards.
*
* @param branches space separated list of expressions.
* Returns the pattern corresponding to the branches containing wildcards.
*
* @param branches space separated list of expressions.
* For example "*" which would match all branches and branch* would match branch1, branch2, etc.
* @return pattern corresponding to the branches containing wildcards (ready to be used by {@link Pattern})
*/
Expand Down