Chris Wallis
Chris Wallis

Reputation: 1273

TeamCity build.counter parameter in build.xml

It seems that the TeamCity parameter ${build.counter} is not resolving in our ant build.xml. We have:

<replaceregexp 
        file="AndroidManifest.xml"
        match='android:versionCode="(.*)"'
        replace='android:versionCode="${build.counter}"'
/>

This throws the error:

String types not allowed (at 'versionCode' with value '${build.counter}')

It looks like it is taking the parameter "${build.counter}" as a literal string.

Using another TeamCity integer parameter in place of ${build.counter}, for example ${teamcity.build.id}, works fine.

Does anyone know why this might be?

Update

Thanks Biswajit_86 for the answer. Here also is my related discussion with JetBrains:

Upvotes: 1

Views: 1825

Answers (2)

Mohammad Nadeem
Mohammad Nadeem

Reputation: 9392

Ant won't read teamctiy varaibles directly. You'll need to create a similar build.counter property in your ant project like:

<property name="build.conuter" value=""/>

and pass its value from Teamcity build step like:

enter image description here

Upvotes: 0

Biswajit_86
Biswajit_86

Reputation: 3739

Your build files wont know the value of build.counter at all. They can only read system properties but build.counter is a config parameter.

To do this declare a system parameter named system.BUILD.COUNTER whoose value is %build.counter% and pass this into your target. If you change your abnt build.xml to read ${BUILD.COUNTER}, it will work fine

build parameters section system.BUILD.COUNTER %build.counter%

build xml file

<replaceregexp 
        file="AndroidManifest.xml"
        match='android:versionCode="(.*)"'
        replace='android:versionCode="${BUILD.COUNTER}"'
/>

Upvotes: 3

Related Questions