TeamCity 参数 ${build.counter} 似乎没有在我们的 ant build.xml 中解析。我们有:
<replaceregexp
file="AndroidManifest.xml"
match='android:versionCode="(.*)"'
replace='android:versionCode="${build.counter}"'
/>
这会引发错误:
String types not allowed (at 'versionCode' with value '${build.counter}')
看起来它正在将参数“${build.counter}”作为文字字符串。
使用另一个 TeamCity 整数参数代替 ${build.counter},例如 ${teamcity.build.id},效果很好。
有人知道为什么会这样吗?
更新
感谢 Biswajit_86 的回答。这也是我的 related discussion with JetBrains :
最佳答案
您的构建文件根本不知道 build.counter 的值。它们只能读取系统属性,但 build.counter 是一个配置参数。
为此,声明一个名为 system.BUILD.COUNTER 的系统参数,其值为 %build.counter% 并将其传递到您的目标中。如果您将 abnt build.xml 更改为 ${BUILD.COUNTER},它将正常工作
构建参数部分 system.BUILD.COUNTER %build.counter%
构建xml文件
<replaceregexp
file="AndroidManifest.xml"
match='android:versionCode="(.*)"'
replace='android:versionCode="${BUILD.COUNTER}"'
/>
关于android - build.xml 中的 TeamCity build.counter 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24508276/