android - build.xml 中的 TeamCity build.counter 参数

标签 android ant teamcity teamcity-8.0

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/

相关文章:

Android:静态获取上下文是一种好习惯吗?

android - 以编程方式启动移动网络设置屏幕

java - 处理多个文件的 Ant exec 命令参数

java - 我可以在 ant 构建脚本中设置执行的相对路径吗?

TeamCity : The process cannot access the file because it is being used by another process中的NuGet错误

teamcity - 在 TeamCity 中更改构建模板

android - 在Android中使用YouTube视频自定义ListView

java - 与 android 包冲突 - Amazon SNS

linux - 如何使用Pid通过Ant命令杀死linux进程

git - TeamCity:如何将未版本化的配置文件放入 checkout 的存储库中?