跳转至

TeamCity

Windows下代理安装

配置文件

/conf/buildAgent.dist.properties文件复制一份,重命名为buildAgent.properties。填写配置项

serverUrl=http://192.168.31.200:28111/
name=ci-agent1

/bin/agent.bat start启动,无报错则可在Teamcity Server看到此agent。

服务

正常启动成功后,使用批处理安装为服务,以供开机启动。

/bin/service.install.cmd
/bin/service.start.cmd

如果启动服务报错Unable to execute Java command. 系统找不到指定的文件。 (0x2),修改配置文件C:\opt\buildAgentFull\launcher\conf\wrapper.conf中的启动命令:java改为实际的java路径

image-20250810154028180

Linux 下自动启动代理

创建 systemd 服务

sudo vi /etc/systemd/system/teamcity-agent.service
/etc/systemd/system/teamcity-agent.service
[Unit]
Description=TeamCity Build Agent
After=network.target

[Service]
Type=oneshot

User=root
Group=root
ExecStart=/mnt/disk1/appdata/teamcity-agent/buildAgentFull/bin/agent.sh start
ExecStop=-/mnt/disk1/appdata/teamcity-agent/buildAgentFull/bin/agent.sh stop kill

# Support agent upgrade as the main process starts a child and exits then
RemainAfterExit=yes
# Support agent upgrade as the main process gets SIGTERM during upgrade and that maps to exit code 143
SuccessExitStatus=0 143
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
#NoNewPrivileges=true

[Install]
WantedBy=default.target

启用、启动服务

sudo systemctl enable teamcity-agent.service
sudo systemctl start teamcity-agent.service

SELinux 放行

sudo grep avc /var/log/audit/audit.log | audit2allow -M teamcity_agent
sudo semodule -i teamcity_agent.pp

Agent 显示中文乱码

配置文件在 BuideAgent 的安装路径下的 conf/buildAgent.properties,行尾回车,添加如下配置:

buildAgent.properties
teamcity.agent.jvm.file.encoding=UTF-8

修改完成需要重启服务,成功后再Web界面能查询到。

image-20250318232950755