In this post I show how to setup Mq patches with TeamCity build.
First of all, let's start with basics. I decided to use Mq extension to deal with patches to a opensource library with sources under Mercurial. The goal was to have a build configuration that fetches sources from the library repository, applies patches from patches repository, builds, tests and packages the library.
Mq Basics
For local checkout on local machine to apply patches you need the following:
- enable Mq extension for your Mercurial
- hg clone remote-repo local-folder
- hg clone pathces-remote-repo local-folder/.hg/patches
- hg qpull -a
At the end you see all your patches applied or you see a patch application error. For more details, please refer to original Mq docs.
Setting up TeamCity Checkout
First we need to select checkout on agent for the build configuration as we need to call Mercurial commands to apply patches. All hg clone commands are replaces with TeamCity VCS root and checkout rules. TeamCity will take care of checkout better.
I add one VCS root that checks out the library repository with no checkout rules and the one VCS root for patches repository with checkout rules +: . => .hg/patches to checkout patches repository to patches repository location.
You need to set Clean all files before build to make TeamCity revert all changes before the next build.
To make Mercurial checkout on agent work, check you have Mercurial installed locally.
Setting up the Patch
Next step is to enable Mq extension (nice that it's embedded into default Mercurial install) and apply the patch:
I use Command Line build runner to call the script and put it as the first build step. The command succeeds only if Mercurial was able to apply patches and thus the build continues
Use
I used the described approach for patches to OData4j library: https://code.google.com/p/odata4j-patches. I set up TeamCity Build Configuration for that
comments powered by Disqus