Skip to content

Commit 55ea389

Browse files
KalleOlaviNiemitalonfalco79
authored andcommitted
[JENKINS-75083] Build statuses do not appear in list of pull requests in Bitbucket Server (#954)
Set "ref" in PR build status for Bitbucket Server
1 parent b0b29bd commit 55ea389

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotifications.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,20 @@ private static void sendNotifications(BitbucketSCMSource source, Run<?, ?> build
223223
* Poor documentation for bitbucket cloud at:
224224
* https://community.atlassian.com/t5/Bitbucket-questions/Re-Builds-not-appearing-in-pull-requests/qaq-p/1805991/comment-id/65864#M65864
225225
* that means refName null or valued with only head.getBranchName()
226-
* For bitbucket server refName set to null or ... (refs/heads/ + head.getBranchName()) ??
226+
*
227+
* For Bitbucket Server, refName should be "refs/heads/" + the name
228+
* of the source branch of the pull request, and the build status
229+
* should be posted to the repository that contains that branch.
230+
* If refName is null, then Bitbucket Server does not show the
231+
* build status in the list of pull requests, but still shows it
232+
* on the web page of the individual pull request.
227233
*/
228-
refName = null;
229234
bitbucket = source.buildBitbucketClient(head);
235+
if (BitbucketApiUtils.isCloud(bitbucket)) {
236+
refName = null;
237+
} else {
238+
refName = "refs/heads/" + head.getBranchName();
239+
}
230240
} else {
231241
listener.getLogger().println("[Bitbucket] Notifying commit build result");
232242
SCMHead head = rev.getHead();

0 commit comments

Comments
 (0)