The Simplest Way to Make Cloud Run and Mercurial Work Like They Should
Pairing cloud run and mercurial lets your team run code builds on demand. A code push triggers a container that tests or deploys your app. Many teams still rely on Mercurial for large code repos. They also want modern cloud tools that scale down to zero. Running stateless containers from your repo events bridges this gap well. You only pay for compute time while your job runs. How cloud run and mercurial share data and roles The workflow between cloud run and mercurial starts with a repo eve
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.
Pairing cloud run and mercurial lets your team run code builds on demand. A code push triggers a container that tests or deploys your app.
Many teams still rely on Mercurial for large code repos. They also want modern cloud tools that scale down to zero. Running stateless containers from your repo events bridges this gap well. You only pay for compute time while your job runs.
How cloud run and mercurial share data and roles
The workflow between cloud run and mercurial starts with a repo event. A developer pushes new changes to the central Mercurial server. The server runs a hook that sends a web request out. That request wakes up your container service in Google Cloud.
First, the Mercurial server must prove its identity to Google Cloud. It uses a dedicated service account to sign its web request. Cloud Run checks the token before it starts any new container. If the check passes, the container boots and reads the payload.
Next, the running container needs to pull the latest source code. It uses its assigned role to read a secret key from storage. The container uses that key to log in to the Mercurial server. It clones the exact commit and runs your build or test job.
Data flows both ways during this process. Mercurial sends commit details like branch names and author tags. The container sends test status results back to the repo server. Every step relies on clear permissions at both ends of the pipe.
Common failure modes and how to scope access
Teams often take shortcuts when they first wire these two tools together. A common mistake is using one shared SSH key for all jobs. If that single key leaks, an attacker can read every repo. Revoking that key also breaks all of your active cloud services.
Broad cloud roles create another big risk for your team. Sometimes an engineer gives the container service an admin role to fix errors. If bad code runs inside that container, it can delete cloud resources. Overly broad tokens turn a small bug into a major outage.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged repo pulls also hurt your security posture over time. When ten services share one login, your audit logs look identical. You cannot tell which cloud job pulled a secret branch at midnight. Your security team needs clear records for every single code clone.
You can fix these issues with tight role and network rules. Give each container service its own unique Google Cloud service account. Map each service account to a specific read-only user in Mercurial. Limit that user so it only reads the one repo it needs.
Store all repo keys inside a managed secret store. Grant each container role permission to read only its own secret. Rotate these keys on a set schedule to limit exposure time. Never bake repo keys or passwords directly into your container images.
Lock down the network path between your cloud project and repo server. Use a private network connector so traffic stays off the public internet. Set your Cloud Run ingress rules to reject unknown web traffic. Allow requests only from your verified repo server IP addresses.
Good logging closes the loop on your setup. Turn on audit logs for both your secret store and container requests. Log the commit hash and service account name for every build run. When a build fails, your team can trace the exact cause 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
Can a container keep a local copy of a Mercurial repo?
No, containers on this platform are stateless and wipe local disks on shutdown. Your container must clone or pull the needed files on each cold start.
How should a Mercurial hook trigger a private container service?
The hook should request a short-lived identity token from a Google service account. It includes this token in the request header to pass the login check.
What is the safest way to give containers read access to code?
Create a read-only repo user for each service and store the key externally. The container fetches its key at runtime and deletes it when the job ends.
Related guides
In this post