The Simplest Way to Make Gerrit and Teamcity Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Engineers use gerrit and teamcity together to check every code change before a merge. Gerrit holds pending patches while TeamCity runs tests and sends back a pass or fail score. This pairing keeps broken code out of your main branch. Developers push a change to Gerrit for peer review. TeamCity spots the new patch and starts a test build right away. When the build finishes, TeamCity posts a vote back to the review page. Human reviewers see the test score before they read a single line of code. T

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.

Engineers use gerrit and teamcity together to check every code change before a merge. Gerrit holds pending patches while TeamCity runs tests and sends back a pass or fail score.

This pairing keeps broken code out of your main branch. Developers push a change to Gerrit for peer review. TeamCity spots the new patch and starts a test build right away. When the build finishes, TeamCity posts a vote back to the review page. Human reviewers see the test score before they read a single line of code. This setup saves time and stops bad merges before they happen.

How data and roles flow between gerrit and teamcity

Gerrit acts as the gatekeeper for all Git repos in your stack. Every developer commit goes into a special staging ref instead of the main branch. TeamCity watches these refs or listens for change events from the review server. When a new patch arrives, the build server fetches that exact commit over SSH or HTTPS.

To make this work, TeamCity needs its own user account inside Gerrit. You must grant this bot account permission to read the target repo refs. It also needs permission to cast review votes on open changes. Once the build agent finishes the test suite, the server sends a message back. That message sets a verified label on the exact patch set it just tested. If a developer uploads a new fix, the whole loop starts over again.

Common failure modes and how to scope access

Many teams take shortcuts when they set up the build bot account. They give the TeamCity user full admin rights across all Gerrit projects. If an attacker steals that build key, they can read or alter any repo. A broad key also lets a broken build job post votes on the wrong projects.

Shared service keys cause trouble during audits too. When five build servers share one SSH key, your logs lose clear detail. You cannot tell which server pulled a secret repo or changed a review state. Unlogged queries between the build nodes and the code host hide slow network bugs.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix these risks with tight role rules and clear network paths. Give the TeamCity bot account read and vote rights only on active build projects. Never give the build bot permission to submit or merge code on its own. Rotate the bot SSH keys or HTTP tokens on a set schedule. Restrict the network path so only known TeamCity servers can reach the Gerrit port. Log every git fetch and review vote with a clear server name and timestamp.

Keeping build queues fast as teams grow

Large engineering teams push hundreds of patch sets every single day. If TeamCity polls every repo every minute, Gerrit starts to slow down. Polling creates heavy database load and delays git fetches for human developers. Event streams or webhooks solve this problem by sending alerts only when code changes.

You should also split quick lint checks from long test suites. Run fast checks first so developers get feedback in two minutes. Only start the heavy test jobs after the fast checks pass. This simple rule keeps your build agents free and your review queue moving fast.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How does TeamCity know when a new Gerrit patch arrives?

TeamCity can watch the Gerrit event stream or poll the git staging refs. Event streams work best because they start builds right away without extra server load.

What permissions does the TeamCity bot need in Gerrit?

The bot needs read access on target refs and permission to set the verified label. It should never have admin rights or permission to merge changes into main.

Why did TeamCity run a build but fail to post the score?

This usually happens when the bot account lacks label voting rights on that branch. Check your Gerrit project access rules to make sure the bot group can vote.

The query runs. The emails stay hidden.