Bitbucket Server and/or Data Center not able to send commit notification to Bamboo due to incorrect proxy settings
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.
You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.
We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!
Summary
This page covers an issue where Bitbucket Server and/or Data Center fails to send commit information to Bamboo due to some missing configuration on the proxy which sits between Bitbucket Server and/or Data Center and Bamboo. This prevents Bamboo from automatically triggering builds based on changes made in Bitbucket Server and/or Data Center since the commit information never arrives in Bamboo.
Environment
Any supported Bamboo and Bitbucket Server and/or Data Center versions.
This page was created considering the below traffic structure between Bamboo and Bitbucket Server and/or Data Center.
Client -> HTTPS -> F5 -> HTTP -> Ingres/ (port 80) -> HTTP -> Bamboo
Client -> HTTPS -> F5 -> HTTP (7990) -> Bitbucket
Diagnosis
The following actions can be taken to diagnose the issue and confirm that you're running into the problem described in this article:
- The first step is to enable the debug logs in Bitbucket Server and/or Data Center, this will provide us information in the logs on whether the commit information was sent to Bamboo or not. For that please refer to the "Enable debug logging" page.
When analyzing <bitbucket-home>/log/atlassian-bitbucket.log you should see the following warning messages in the logs which confirm that Bitbucket is not able to send remote notifications to Bamboo:
WARN [events.remote.ratelimit.threads:thread-1] c.a.e.r.impl.RemoteEventDispatcher Failed to send events
Next you'll see "Request url isn't in the same origin as the rpc url" errors inside the <bitbucket-home>/log/atlassian-bitbucket.log file:
Sending 1 event(s) to http://example-bamboo.com/rest/remote-event-consumer/latest/events/stash-pullrequest-opened-remote-event java.lang.IllegalArgumentException: Request url 'http://example-bamboo.com/rest/remote-event-consumer/latest/events/stash-pullrequest-opened-remote-event' isn't in the same origin as the rpc url 'https://example-bamboo.com'
Please note that the request url is http://example-bamboo.com (insecure) is different to rpc url which is https://example-bamboo.com (secure).
Bitbucket sends a request to the following Bamboo REST endpoint:
https://example-bamboo.com/rest/remote-event-consumer/1/capabilities
You can issue a cURL to check the response from Bamboo:
curl -vvv https://example-bamboo.com/rest/remote-event-consumer/1/capabilities
The output will advertise an http url (instead of https):
curl -vvv https://example-bamboo.com/rest/remote-event-consumer/1/capabilities {"stash-branch-changed-remote-event":"http://example-bamboo.com/rest/remote-event-consumer/latest/events/stash-branch-changed-remote-event"
In the example above you can see that the stash-branch-changed-remote-event is pointing to http instead of https.
Cause
The capabilities endpoint is returning http when it's being accessed over https.
This is happening because either X-Forwarded-Proto or X-Desired-Proto are being set to http by one of the intermediary load balancers (F5) or the ingress on port 80.
Solution
The solution is based on assumption the following traffic structure between Bamboo and Bitbucket
Client -> HTTPS -> F5 -> HTTP -> Ingres/ (port 80) -> HTTP -> Bamboo
Client -> HTTPS -> F5 -> HTTP (7990) -> Bitbucket
- The first step is to configure the F5 to send the X-Forwarded-Proto header with a value that matches the client's protocol, in this case it should be https. Refer this F5 documentation for further details:
- Configure ingress to trust the forwarded headers coming from the IP address of the F5 or configure X-Forwarded-Proto to https, please refer the below 2 articles for syntax and further reading:
- Configure X-Forwarded-Proto to https at the ingress controller:
- After the changes above have been made restart Bamboo and Bitbucket.
After that issue another cURL command to check if Bamboo will advertise the https url. If so Bamboo should start receiving notifications from Bitbucket Server and/or Data Center and automatically trigger builds again.
curl -vvv https://example-bamboo.com/rest/remote-event-consumer/1/capabilities