Bitbucket Server and/or Data Center not able to send commit notification to Bamboo due to incorrect proxy settings
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
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.
*Fisheye および Crucible は除く
本記事で説明している手順は、現時点でのものとなります。そのため、一部のお客様で特定の状況下で動作したという報告がありますが、正式にサポートされているわけではなく、お客様の特定のシナリオで動作することを保証するものではありません。
本番環境での実施の前に一通り非本番環境で検証し、成功しなかった場合にはサポートされている代替案にフォール バックしてください。
要約
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.
環境
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
診断
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.
原因
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.
ソリューション
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