Access source repository log during build

Building .NET projects stored in Mercurial (specifically FogCreek Kiln) using msbuild.

Our build script on FinalBuilder would clone/pull+update a repo, and then invoke a build script in the working copy. That build script would essentially invoke msbuild plus a few other bits and pieces.

One of the msbuild tasks uses a custom “hg.exe log” to find the most recent “vM.m.B” tag from the repo, plus the “tag distance”, and ensures that the assemblies are built with that version.

However, with Continua the build is running on a build agent, and I believe there is no actual .hg folder with the repo history in, so our hg.exe commands don’t work as expected.

I know Continua has versioning stuff built-in, but what’s the idiomatic way using Continua to ensure that is using our repository tags for the semver part of the version?

Many thanks in advance.

Neil.

 Hi Neil,

Continua CI provides expressions under the $Source$ expression object for accessing details related to the repository. This includes $Source.RepoName.LatestTagName$ and $Source.RepoName.CommitsSinceLatestTag$ which you should be able to use to get the information you require.  

If this is not quite what you are looking for, let us know the hg commands that you use, and we’ll investigate whether we can add additional expressions.

That’s fantastic news. Does this support git and mercurial in the same way? I suppose I could set a couple of variables to these values as well (most of the actual build is done in a script in the repository, so all our Continua builds are really just getting source and invoking build.bat in the root)?

Yes, these expressions are available for both git and mercurial (and other repository types). They can be passed as variables to batch files and/or other programs as part of the build process.