TeamCity On-Premises 2025.03 Help

配置代理安装

构建代理可以通过调整 <TeamCity Agent Home>/conf/buildAgent.properties 文件中的设置来配置。

通用代理配置

这个 Java 属性配置文件可以存储将在服务器上发布为 代理属性的属性,并可以参与 代理要求表达式。 所有在文件中定义的 系统和环境属性都将传递给在 agent 上运行的每个构建。

语法参考:

  • 使用 property_name=value<newline> 语法。

  • # 用于行的首位以进行注释。

  • 使用 / 而非 \ 作为路径分隔符。 如果您需要包含 \ ,请用另一个 \ 进行转义。

  • 空白字符会像其他任何符号一样被处理。

示例代理配置文件:

## The address of the TeamCity server. The same as is used to open the TeamCity web interface in the browser. ## Must include the protocol specification (https:// is recommended). serverUrl=http://localhost:8111/ ## The unique name of the agent used to identify this agent on the TeamCity server ## Use blank name to let server generate it. ## By default, this name would be created from the build agent's host name name=Default agent ## Container directory to create default checkout directories for the build configurations. workDir=../work ## Container directory for the temporary directories. ## Please note that the directory may be cleaned between the builds. tempDir=../temp ## Container directory for agent state files and caches. ## TeamCity agent assumes ownership of the directory and can delete the content inside. systemDir=../system ###################################### # Optional Agent Properties # ###################################### ## A token which is used to identify this agent on the TeamCity server for agent authorization purposes. ## It is automatically generated and saved back on the first agent connection to the server. authorizationToken=1234567890abcdefghijklml

确保构建代理进程本身可以写入该文件。 例如,该文件已经更新,以存储在服务器端生成的授权令牌。

如果您安装了多个 TeamCity 节点 在反向代理后serverUrl 应设为代理 URL。

如果 名称 属性未被指定,服务器将会自动生成构建代理名称。 默认情况下,此名称将从构建代理的主机名创建。

当代理运行时,可以编辑该文件:代理检测到更改,并在(如果有)完成运行的构建后自动重启,加载新的设置。

可选属性

构建代理端口

TeamCity 构建代理启动并侦听来自服务器的传入数据的端口是通过 ownPort 属性确定的(默认为 9090)。 如果防火墙已配置,请确保代理机上允许此端口的入站连接。

ownPort=9090

如果同一台机器上托管了多个构建代理,必须通过每个代理的 buildAgent.properties 文件中的 ownPort 属性为它们分配不同的端口。

构建代理 IP 地址

当代理首次连接到 TeamCity 服务器时,该代理会自动确定其用于连接的 IP 地址,除非已定义 ownAddress 属性。 如果代理机器有多个网络接口,自动检测可能会失败。 在这种情况下,建议指定 ownAddress 属性:

ownAddress=<own IP address or server-accessible domain name>

备用获取 URL

如果您有一个自我更新的 Git 仓库代理,该代理比某些代理的原始 Git 仓库要近得多,那么您可以允许这些代理从这个镜像下载源码。 为此,将 teamcity.git.fetchUrlMapping.<name>=<original URL> => <proxy URL> 设置添加到代理配置文件中。 请参阅此部分以获取更多信息: Git VCS 根目录 | 通用设置

配置命令

要设置 buildAgent.properties 文件,您可以运行 <Agent_folder>/bin/agent.bat<Agent_folder>/bin/agent.sh 脚本,并使用 configure 命令。 此命令允许您设置核心代理属性并将其保存到目标配置文件中。 如果未指定配置文件路径,更改将保存到默认 <Agent_folder>/conf/buildAgent.properties 属性。

要查看可用参数列表,请使用 --help 标志运行此命令。

./agent.sh configure --help Java executable is found: '/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home/bin/java' Configuring TeamCity build agent... TeamCity Agent configurator Usage: configure PROPERTIES_FILE configure -f PROPERTIES_FILE configure [PROPERTIES] configure --usage status status short Where PROPERTIES format is --key=value or --key value Supported properties: * --agent-config-file=PATH - path to build agent properties file (<Agent Root>/conf/buildAgent.properties by default) * All default properties that can be configured in buildAgent.properties file Also there are aliases for some of them: address = ownAddress auth-token = authorizationToken logs-dir = logsDir name = name port = ownPort server-url = serverUrl system-dir = systemDir temp-dir = tempDir work-dir = workDir

示例命令,记录服务器 URL 并设置自定义代理名称:

./agent.sh configure --server-url http://localhost:8111/ --name AG2

设置代理服务器后的代理

可以配置前向代理服务器以便代理到服务器的连接。

在 TeamCity 代理端,使用 buildAgent.properties 文件中的以下属性来指定连接到 TeamCity 服务器的代理:

## The domain name or the IP address of the proxy host and the port teamcity.http.proxyHost=123.45.678.9 teamcity.http.proxyPort=8080   ## If the proxy requires authentication, specify the login and password teamcity.http.proxyLogin=login teamcity.http.proxyPassword=password

要访问 HTTPS 端点(例如,托管在 GitHub 上的存储库),还需配置 teamcity.https.* 属性。

最后修改日期: 2025年 3月 21日