準(zhǔn)備
首先確定自己是否可以訪問已經(jīng)搭建好的TeamCity的服務(wù)網(wǎng)站.
進(jìn)入網(wǎng)站的"Agent"頁面
點(diǎn)擊Install Build Agents
配置
解壓縮后,
BUILD_46654
conf
launcher
plugins
bin
contrib
lib
service.properties
以conf下的buildAgent.dist.properties文件作為模板, 編寫一個(gè)buildagent.properties文件
cp conf/buildAgent.dist.properties conf/buildAgent.properties
參考這里修改conf/buildAgent.properties文件.
主要修改如下的幾點(diǎn):
- serverUrl 修改為TeamCity的網(wǎng)址
- name 改成一個(gè)特定的名字
authorizationToken可以先不用管
配置代理(可選步驟)
有些時(shí)候, 需要通過代理服務(wù)器來打通TeamCity服務(wù)和其他服務(wù)(比如bug服務(wù)器). 代理服務(wù)器的配置方法不難, 可以參考這里
如果Agent也需要通過代理訪問, 則需要補(bǔ)充如下的配置:
## The URL or the IP address of the proxy host
teamcity.http.proxyHost=123.45.678.9
## The optional proxy port, leave blank to use the default port
teamcity.http.proxyPort=1234
## If the proxy requires authentication, specify the login
teamcity.http.proxyLogin=login
## If the proxy requires authentication, specify the password
teamcity.http.proxyPassword=password
運(yùn)行
bash-3.2$ bin/agent.sh start
Starting TeamCity build agent...
Java executable is found in '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home'.
Starting TeamCity Build Agent Launcher...
Agent home directory is /Users/jianglei/Downloads/buildAgent
Current Java runtime version is 1.8
Lock file: /Users/jianglei/Downloads/buildAgent/logs/buildAgent.properties.lock
Using no lock
Done [10112], see log at /Users/jianglei/Downloads/buildAgent/logs/teamcity-agent.log
登錄TeamCity網(wǎng)站, 會(huì)看到還未認(rèn)證的Agent信息
WechatIMG3.jpeg
點(diǎn)擊Unauthorized, 輸入comments設(shè)置agent所在的pool, 就可以了
可能遇到的問題
- 如果TeamCity服務(wù)不是https的, 可能需要使用配置agent和服務(wù)端使用rpc-xml協(xié)議
WechatIMG4.jpeg
需要在服務(wù)端修改一下配置. 增加上圖的配置
- agent的初始狀態(tài)往往是disconnected, 從log上可以看出來是Agent還需要從服務(wù)端下載插件并升級(jí)(upgrade). 一般等待10幾分鐘(取決于網(wǎng)速)就恢復(fù)正常了.