How to trigger Bamboo builds with GitHub webhook
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
Summary
Repository Polling is added by default when configuring a GitHub repository in Bamboo and its design is to frequently detect changes in the source code, periodically or based on a schedule which may not be the best strategy for all build plans, since they tend to overload the server with scheduled tasks to check the remote repository and this can reduce the server performance.
The steps from this article are intended to allow you to use a different configuration that will remove the cost of frequent remote repository checks.
Environment
All supported versions of Bamboo.
Solution
Configuration steps
- The Bamboo instance needs to be reachable through the internet. Otherwise, GitHub will not be able to find it to trigger a build.
- If you already have a polling trigger configured, remove it. Go to Plan configuration >> Triggers and remove the polling trigger.
- Add the Remote Trigger to the plan you want GitHub to trigger.
- Enter the list of addresses (CIDR Notation compatible) that can trigger builds in Bamboo.
- The list of GitHub IP addresses for outbound POST requests by Webhooks can be retrieved from GitHub's meta API endpoint.
- Bamboo's IP allowlist also inspects the X-Forwarded-For HTTP header to determine the origin of the request. If you have a reverse proxy forwarding requests to your Bamboo instance, depending on its configuration, you may also need to add to the allowlist the IP address of the Proxy Server.
- Make sure the anonymous users can trigger builds. Go to Overview >> Security >> Security settings >> Check the option '[x] Allow anonymous users to trigger remote repository change detection and Bamboo Specs detection'
Configure GitHub to call the following Bamboo REST API:
https://<BAMBOO_URL>/rest/triggers/latest/remote/changeDetection?planKey=<PLAN-KEY>
The above steps should be enough to configure the Bamboo instance for remote triggers from GitHub.
- Make sure that the Content-type field is set to application/json
The "skipBranches" can be appended to the endpoint URL to determine whether change detection will be triggered by this event for every branch on the plan (false), or just the plan key specified (true).
i.e.:
https://<BAMBOO_URL>/rest/triggers/latest/remote/changeDetection?planKey=<PLAN-KEY>&skipBranches=false
For more details about remote triggers please visit the official documentation.