Wednesday, February 2, 2011

Generate current Git version in Ant for Hudson

At the time I wrote this blog there is no Git Ant task. Workaround for getting current commit version is to use exec directly invoke git describe as below.
<exec executable="git" outputproperty="build.commit">
    <arg value="describe"/>
    <arg value="--tags"/>
    <arg value="--abbrev=20"/>
</exec>

Now you can get result value of git describe from ${build.commit}.
Credit: How to lookup the latest git commit hash from an ant build script - Stack Overflow

But there is also some problems with Hudson's git plug-in which it always tags build revision that causes our git describe return the wrong result. There was someone send patch to fix this but this is not build to the plug-in yet. Currently workaround is provided in that patch page, add paramter to git describe, "--match=[^(hudson)]*", to ignore tag from Hudson. So we have to add more arg line to Ant's exec task:
<arg value="--match=[^(hudson)]*">

That's all.

No comments:

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...