The Simplest Way to Make CircleCI and Mercurial Work Like They Should
Teams use circleci and mercurial together to run automated builds from source code changes. This setup lets your build server test every code push in a clean runner. Many older projects still keep their source code in Mercurial repos. At the same time, modern engineering teams want fast cloud build pipelines. Linking these two tools takes a clear plan for webhooks and keys. Most cloud build tools expect Git repos by default. Because of this, you must set up a custom flow to link them. When you
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 circleci and mercurial together to run automated builds from source code changes. This setup lets your build server test every code push in a clean runner.
Many older projects still keep their source code in Mercurial repos. At the same time, modern engineering teams want fast cloud build pipelines. Linking these two tools takes a clear plan for webhooks and keys. Most cloud build tools expect Git repos by default. Because of this, you must set up a custom flow to link them. When you do this right, developers push changes and get fast test feedback.
How circleci and mercurial handle keys and data flow
Data moves from your source host to the build runner through webhooks. A developer pushes a code change to the central Mercurial server. That server sends a small web message to trigger the build job. The message holds the branch name and the commit hash.
Next, the build runner starts a fresh container or virtual machine. Since the default checkout step expects Git, you skip that standard step. Instead, you install the Mercurial client inside the build runner image. You also load a private SSH key or API token into the runner. The runner uses this key to log in and pull the exact commit. Once the files arrive, the runner runs your test scripts and builds the app. Finally, the runner sends the pass or fail status back to your team.
Common failure modes and how to scope roles
The biggest risk in this workflow comes from shared service accounts. Teams often create one powerful admin key and paste it into many build projects. If a bad actor steals that key, they can read or delete all code. Broad tokens also let a broken build script push bad tags back to main. Another common issue is a lack of clear audit logs. When ten pipelines share one login, you cannot tell which job pulled what code.
You can fix these gaps by scoping down every single role and key. Give each project its own read-only key for code checkout. Never let a standard test runner have write permissions to your code server. If a build job must talk to a database, mask sensitive test data. Data masking rewrites matched fields like emails, phone numbers, and card numbers in results. You should also lock down network paths between the cloud runner and private hosts. Allow traffic only from known runner IP addresses or use a private runner inside your network. Rotate your build keys on a regular schedule to keep the pipeline safe.
End-to-End Encryption + CircleCI Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Best practices for fast code checkouts
Large repos can slow down your build times if you clone everything each run. A full clone pulls years of history that a simple unit test never needs. You can speed this up by caching the repo folder between build runs. When the next job starts, it loads the cache and pulls only new changes.
Also, build a custom container image that already has the Mercurial client installed. This step saves time because the runner does not download tools on every build. Keep your webhook trigger rules tight so you only run builds on active branches. These small steps keep your queue short and save build minutes for your team.
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
Can CircleCI pull code from Mercurial out of the box?
No, the built-in checkout step supports Git repos only. You must run a custom command step with the Mercurial client to pull code.
How do we trigger a build when a developer pushes to Mercurial?
Set up an outgoing webhook or post-push hook on your Mercurial server. Have that hook send a request to the CircleCI API to start a pipeline.
What permissions should the build runner key have on the code server?
Give the build key read-only permissions scoped to that single repo. Only add write permissions to isolated release jobs that must push version tags.
Related guides
In this post