TeamCity

我们团队使用的TeamCity的一个BuildAgent一直有乱码的问题,每次输出的日志都是一堆“?????”。正常情况还好,在CI出现问题、需要trouble shooting时,简直要命。

所以我查了一下怎么通过配置BuildAgent的构建参数来指定编码格式。

以linux为例。配置文件在BuideAgent的安装路径下的conf/buildAgent.properties。打开文件后,里面有配置说明和示例:

######################################
#   Default Build Properties         #
######################################
## All properties starting with "system.name" will be passed to the build script as "name"
## All properties starting with "env.name" will be set as environment variable "name" for the build process
## Note that value should be properly escaped. (use "\\" to represent single backslash ("\"))
## More on file structure: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
# Build Script Properties
#system.exampleProperty=example Value
# Environment Variables
#env.exampleEnvVar=example Env Value

注释和示例的意思是,在这个文件中,以system或env开头的配置项,分别对应TeamCIty的Agent管理界面上的System Properties和Environment Variables参数:

图片

但是,Configuration Parameters呢?它的前缀是什么呢?

通过TeamCity的官网文档可以查到:

图片

也就是说,Configuration Parameters是不需要前缀的。

这样,直接在buildAgent.properties中加一行配置,以指定这个BuildAgent在运行时的编码格式就可以了:

teamcity.agent.jvm.file.encoding=UTF-8
``