The Simplest Way to Make Bitbucket and CockroachDB Work Like They Should
You pair bitbucket and cockroachdb to automate schema changes from code commits. Your build pipeline reads SQL files in Git and runs them on the database. Teams use this setup to keep code and database tables in sync. Every merge request can test schema scripts before they hit production nodes. When a release merges, the runner applies the new tables right away. Yet this setup creates big security gaps when teams rush the work. How bitbucket and cockroachdb talk in production First, an engin
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.
You pair bitbucket and cockroachdb to automate schema changes from code commits. Your build pipeline reads SQL files in Git and runs them on the database.
Teams use this setup to keep code and database tables in sync. Every merge request can test schema scripts before they hit production nodes. When a release merges, the runner applies the new tables right away. Yet this setup creates big security gaps when teams rush the work.
How bitbucket and cockroachdb talk in production
First, an engineer pushes a code branch or merges a pull request. This Git event starts a build runner inside your cloud workspace. The runner pulls the repo files and starts a migration tool. Next, the runner needs a way to log in to the database cluster.
Most teams store a database password or key inside the repo settings. The runner grabs this secret from memory and opens a network link. It talks to the database over the wire using standard PostgreSQL drivers. Then the runner sends SQL commands to update tables or add indexes. The database checks the user role and runs the requested changes. When the job ends, the runner closes the link and saves the build log.
This flow works well for small apps with one or two builders. As the team grows, static secrets in repo settings become hard to track. Anyone who can edit the build script can print or steal that secret. A compromised runner can wipe tables or read private customer rows.
Common failures when linking pipelines and databases
The biggest mistake is using one admin account for every build pipeline. Teams often grant full root rights so migration scripts never fail. If a bad query slips into a branch, it can drop live tables. Shared accounts also ruin your audit logs during an incident check. Every query in the database log just shows the same shared pipeline user. You cannot tell which commit or person ran a destructive command.
End-to-End Encryption + Bitbucket Pipelines Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Wide network rules create another major risk for your data nodes. Cloud runners often use a huge pool of changing IP addresses. To let the runner in, admins sometimes open the database port to all traffic. That exposes your cluster to brute force attacks and external scans. Instead, run your build jobs on private workers inside your own network. Keep the database off the public internet and use private links.
Scoping roles and protecting sensitive data in builds
Split your database users by task and stage to limit blast radius. Give your test branch runners a role that only touches test schemas. Production runners should only have rights to alter tables, not read user rows. Never let a build job read raw emails, phone numbers, or card numbers. If a developer needs to run a manual fix, require a peer review.
Rotate your database keys and certs on a strict schedule. Remove old secrets from repo settings as soon as a project ends. Check your database logs each week for strange queries from build hosts. When you keep roles small and networks tight, your pipelines stay safe.
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 should build runners log in to the database cluster?
Use client certs or short-lived tokens instead of static passwords. Pair those keys with a dedicated database role that only alters schema objects.
Why do teams avoid public IP allowlists for cloud runners?
Cloud build runners share broad IP ranges with many other customers. Opening those ranges lets outside systems reach your database login port.
How can we prevent a bad commit from dropping production tables?
Run schema checks in a staging cluster during the pull request step. Require a human approval step before the production pipeline job can start.
Related guides
In this post