4

I build my Android apps with Jenkins on a Linux Ubuntu server and uses Bazaar as SCM.

I'd like to automatically append the bazaar revision id of the project to the value of Android:versionName in my manifest file.

I use ant to build and I have the Jenkin's bazaar plugin that passes the revid to the ant build script, but I have no idea how to do that.

jmc34
  • 810
  • 3
  • 10
  • 22
  • It's unclear which part you're having trouble with. Is it how do you get the bzr revid passed to the ant build script or how do you use the revid in the ant build script to modify your manifest file? – dOxxx Nov 09 '11 at 18:39
  • Sorry, I missed your comment, I had difficulties on how to modify the manifest file. With more (way more) Googling, I finally found a solution, see below... – jmc34 Nov 10 '11 at 09:06

1 Answers1

4

I finally found a solution here.

It was for SVN, but it has been easy enough to tune for Bazaar...

Here is how my task look like.

<property environment="env"/>
<target name="bzr-revision">
    <echo>Modifying Android manifest with revision: ${env.BZR_REVISION}</echo>
    <!-- Write the revision number into
            the Manifest as the last segment of the VersionName property -->
    <replaceregexp file="AndroidManifest.xml" match='android:versionName="([^".]+\.[^".]+\.[^".]+)(\.[^"]*)?"' replace='android:versionName="\1.r${env.BZR_REVISION}"'/>
</target>

If versionName is 1.5.2, il will replace it with 1.5.2.r123 (where 123 is the Bazaar revision number). You can tune the regex to your needs.

jmc34
  • 810
  • 3
  • 10
  • 22