跳转至

TeamCity

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