Integrating Mercurial with OpenShift for Seamless Builds
The build failed before sunrise. Logs dumped errors about missing sources. The Mercurial repo was working fine the day before, and now OpenShift refused to deploy. There was no warning. Just silence from the pods.
Mercurial and OpenShift are rarely mentioned together. Most teams use Git. But many large, long-running projects still depend on Mercurial. Integrating that workflow into OpenShift is possible, but it requires understanding how OpenShift handles source control, build triggers, and image streams.
OpenShift supports source repositories via its Source-to-Image (S2I) process. By default, it expects Git endpoints. To pull from Mercurial, you need a strategy. One common method: mirror your Mercurial repository to a temporary Git repo with hg convert or hg-git. Then point OpenShift’s BuildConfig to that Git mirror. This ensures standard S2I builds still run without patching OpenShift internals.
If you want a direct Mercurial pull, use a custom build image. Your image must include Mercurial installed and accessible in $PATH. In the Dockerfile, add:
RUN yum install -y mercurial
or the package manager equivalent. Then, modify the BuildConfig to use your custom builder image. Provide the Mercurial repo URL and credentials via OpenShift secrets. Ensure your builder script runs hg clone before starting the build process. This removes the Git requirement entirely.
Watch for branch naming differences. Mercurial handles default branches differently than Git. If your build depends on a branch other than default, pass the exact branch name to your clone command:
hg clone -b release https://your-hg-server/repo
Test your build locally before pushing to OpenShift. This catches environment differences and missing dependencies early.
Once configured, Mercurial integration becomes routine. Builds trigger from updates, deployments roll out through OpenShift’s orchestration, and your legacy source control remains untouched.
Ready to skip the manual setup and see Mercurial work on OpenShift without hours of debugging? Visit hoop.dev and see it live in minutes.