The Simplest Way to Make Bitbucket and Buildkite Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use bitbucket and buildkite together to store code and run fast automated tests. Bitbucket holds the git repos while Buildkite schedules build jobs on your own machines. This setup keeps your source code safe inside your private network. You get cloud dashboards for test results while your own servers run the actual work. Every git push triggers a test run and sends pass or fail statuses back. How bitbucket and buildkite share data and roles The link between these two tools starts with

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use bitbucket and buildkite together to store code and run fast automated tests. Bitbucket holds the git repos while Buildkite schedules build jobs on your own machines.

This setup keeps your source code safe inside your private network. You get cloud dashboards for test results while your own servers run the actual work. Every git push triggers a test run and sends pass or fail statuses back.

How bitbucket and buildkite share data and roles

The link between these two tools starts with webhooks and API keys. When a developer pushes code, Bitbucket sends a webhook message to Buildkite over the web. This message tells the build server which branch changed and who made the commit.

Next, a build agent on your server pulls the code from Bitbucket. The agent uses an SSH key or an API token to read the git repo. Once the build starts, Buildkite sends status updates back to the Bitbucket pull request.

Reviewers can see if the tests pass before they merge the new code. You can also set rules in Bitbucket to block merges until the build passes. This flow keeps bad code out of your main branch.

Each direction of traffic needs its own permission rule to stay safe. Webhook traffic goes from the source host to the build service. Source code pulls go from your own build runners straight to the git server. Status updates flow back to the git server using a dedicated token.

Common failure modes and how to scope roles

Many teams make the mistake of using one personal account for all build jobs. If that person leaves the company, every single build pipeline breaks right away. A personal account also has broad write access to many repos it does not need.

Shared SSH keys across all build agents create another big risk for your team. If an attacker steals that one key, they can read or change all your code. Instead, you should give each pipeline or agent pool its own scoped key.

End-to-End Encryption + Bitbucket Pipelines Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Give the build agent read-only access to the single repo it needs to test. It rarely needs permission to push code back to the main branch. For status updates, create a dedicated bot account with write access limited to commit statuses.

Unlogged database queries and secret sprawl inside build scripts also cause big problems. Build agents often need database passwords or cloud keys to run full integration tests. Teams often paste long-lived secrets right into pipeline settings and forget to rotate them.

Securing build runners and network paths

Your build agents run untrusted code whenever someone opens a new pull request. Because of this risk, you must lock down the network paths around those runners. Do not put build agents on the same open network as your production databases.

Place your runners in an isolated network zone with strict firewall rules. Allow outbound traffic only to your git server and the package registries you trust. Block runners from talking to internal services unless a specific test needs that path.

You should also clean up the runner disk after every single job finishes. Leftover files or cached keys from one build can leak into the next build. Using fresh containers or temporary virtual machines for each job stops this leak.

Finally, keep a clear log of every resource a build job touches during a run. When a test fails or a key leaks, good logs help you fix it fast. Audit your repo keys and webhook settings every few months to remove unused tokens.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

How does Buildkite trigger a build from Bitbucket?

Bitbucket sends an outbound webhook message whenever a user pushes code or opens a request. The build server reads this event and starts a job on an available agent.

Should build agents use SSH keys or API tokens for git pulls?

Use read-only SSH deploy keys scoped to a single repo whenever you can. If you must use API tokens, tie them to a bot account with narrow roles.

Why are build statuses not showing up on my pull requests?

This usually happens when the API token lacks permission to write commit statuses. Check that your bot account still has valid access to that specific git repo.

The query runs. The emails stay hidden.