1
votes

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:

2
Are you sure that this property resolves at all? Try adding <echo>${build.counter}</echo> right before this step. One random nitpick: your regex replacement doesn't use capture group references, so your match pattern doesn't need parentheses.CAustin
@CAustin - You are right! That gives me "Step 2/2] echo ${build.counter}". So why wouldn't this property resolve when the others do?Chris Wallis
Well to be honest, I don't really know anything about TeamCity. This is where all your properties are coming from, right? It looks like whichever file is holding these properties is badly formatted, as if it contains build.counter=Step 2/2] echo ${build.counter} or something similar to that.CAustin
That was the log that was generated by your echo line. TeamCity generates these properties at runtime.Chris Wallis
its good ask with Jetbrains, I upvoted.user3584056

2 Answers

3
votes

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}"'
/>
0
votes

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