TeamCity build agent disconnected

落爺英雄遲暮 提交于 2020-06-09 10:57:07

问题


I installed a build agent on Windows 7 and always have the agent show up as "disconnected". The log teamcity-agent.txt shows below information

 If this is the first time this agent registered on the server make sure it is     authorized by administrator in the server web UI. 
[2012-09-05 02:56:14,416]   INFO -    jetbrains.buildServer.AGENT - Agent registration finished. 
[2012-09-05 02:56:14,418]   INFO -    jetbrains.buildServer.AGENT - Stop command was not performed. No build to stop with reason: BuildInterruptReason.AGENT_SHUTDOWN 
[2012-09-05 02:56:14,418]   INFO -    jetbrains.buildServer.AGENT - Starting agent shutdown sequence, reason: Restart agent, failed to download upgrade from server 
[2012-09-05 02:56:14,424]   INFO -    jetbrains.buildServer.AGENT - Host configuration for downloading updates: HostConfiguration[host=http://myteamcity:8080] 
[2012-09-05 02:56:14,424]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/teamcity-agent.xml ==> C:\BuildAgent\temp\iQ0fjie6zR125neulJeqiYauT8zQ5zOI 
[2012-09-05 02:56:15,070]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/agentSystemInfo.zip ==> C:\BuildAgent\update\plugins\agentSystemInfo.zip 
[2012-09-05 02:56:15,747]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/amazonEC2.zip ==> C:\BuildAgent\update\plugins\amazonEC2.zip 
[2012-09-05 02:56:16,617]   INFO - agent.impl.AgentPortFileWriter - Delete agent runtime file from C:\BuildAgent\logs\buildAgent.port 
[2012-09-05 02:56:16,619]   INFO -    jetbrains.buildServer.AGENT - Unregistering from build server: 18 
[2012-09-05 02:56:16,800]   INFO -    jetbrains.buildServer.AGENT - Shutdown agent WebServer start 
[2012-09-05 02:56:16,801]   INFO -    jetbrains.buildServer.AGENT - Shutdown agent WebServer finish 
[2012-09-05 02:56:16,801]   INFO -    jetbrains.buildServer.AGENT - Shutdown agent finish 
[2012-09-05 02:56:16,968]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/ant.zip ==> C:\BuildAgent\update\plugins\ant.zip 
[2012-09-05 02:56:50,086]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/antPlugin.zip ==> C:\BuildAgent\update\plugins\antPlugin.zip 
[2012-09-05 02:56:52,070]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/assembly-info-patcher.zip ==> C:\BuildAgent\update\plugins\assembly-info-patcher.zip 
[2012-09-05 02:56:53,464]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/clearcase-agent.zip ==> C:\BuildAgent\update\plugins\clearcase-agent.zip 
[2012-09-05 02:56:55,375]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/cmake-runner.zip ==> C:\BuildAgent\update\plugins\cmake-runner.zip 
[2012-09-05 02:56:57,190]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/commandLineRunner.jar ==> C:\BuildAgent\update\plugins\commandLineRunner.jar 
[2012-09-05 02:56:58,218]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/coveragePlugin.zip ==> C:\BuildAgent\update\plugins\coveragePlugin.zip 
[2012-09-05 02:57:11,629]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/crashDetector.zip ==> C:\BuildAgent\update\plugins\crashDetector.zip 
[2012-09-05 02:57:12,436]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/cvsAgent.zip ==> C:\BuildAgent\update\plugins\cvsAgent.zip 
[2012-09-05 02:57:20,720]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/dotCover.zip ==> C:\BuildAgent\update\plugins\dotCover.zip 
[2012-09-05 02:58:00,011]   INFO -    jetbrains.buildServer.AGENT - Downloading http://myteamcity:8080/update/plugins/dotNetPlugin.zip ==> C:\BuildAgent\update\plugins\dotNetPlugin.zip 

How can I get the agent connected?


回答1:


Here is a very comprehensive blog on re-connecting disconnected agents

http://michaelbarnesjr.wordpress.com/2012/10/18/teamcity-build-agent-disconnected/

Here are the steps (copied from the above link)

If an agent becomes disconnected for whatever reason, you can follow these steps to re-connect it:

  • ssh to the server that the disconnected agent is on.
  • go to the build agent’s bin directory (i.e. /opt/teamcity/buildagent/buildagent01/bin/)
  • su to the user that the agent runs as (i.e. appBuilder)
  • run agent.sh start

That will start the agent, and after a few seconds or so, the next time you go to TeamCity, it will be connected.

If Team City is running on a windows server, you can connect to that server, go to Services and restart the build agent that has become disconnected. Team City




回答2:


In my case the agent was started but listed as disconnected, after waiting several minutes it was still disconnect. So I went to the bin directory on the build agent like Peter suggested and ran the following two commands

./agent.sh stop
./agent.sh start

essentially just restarting the build agent. That did the trick for me.




回答3:


First, make sure in the TeamCity website dashboard to authorize the agent if you haven't done so already.

Next, make sure the agents "ownPort" is not blocked by a firewall on the agent. This is the port that TeamCity will use to send messages to the agent. The value can be defined in "${agent.home}/conf/buildAgent.properties".

As of TeamCity 2017.2.1, the "ownPort" is not present, nor is there any embedded documentation (i.e. commented out examples). The default value is 8080, but you can just add the property and value you want like this:

## Defines which port the agent will use to receive messages from TeamCity.
## Defaults to 8080 if not present.
ownPort=9091



回答4:


In my case under Windows 8 Professional:

TC build agent upgrade failed

  1. I checked out BuildAgent\logs\teamcity-agent.log, there was trouble with the "upgrade process".

  2. I checked out BuildAgent\logs\upgrade.log, there were more detailed "DEBUG" messages. The problem was "access denied" on shutting down service.

  3. I added the user account of the TC server service to "Administrators" to let it stop the agent service.

  4. I removed the user account of the TC server service from "Administrators" user group.

  5. Restarting both service (TC server + Agent) led finally to have:

    BuildAgent\logs\buildAgent.port
    

    file: the agent was finally connected after successfull.




回答5:


I had issues with the server and change the port for the server.

So, the agent was unable to connect to the server since I only changed the server port and not the agent properties.

Once I updated the agent properties, the agent started working again.

The properties are found under: TeamCity\buildAgent\conf\buildAgent.properties

The property is found like: serverUrl=http://localhost:8080




回答6:


Starting the TeamCity Agent manually in the Services panel resolved the issue for me (on a Windows machine).

Problem was indicated in the upgrade.log (in BuildAgent\logs directory):

ERROR - r.agent.upgrade.UpgradeRunBase - Failed to start agent after upgrade: java.io.IOException: Failed to start TeamCity build agent service. Please check TeamCity build agent service user have enough permissions to stop and start the service. 



回答7:


I ran into this problem when working remotely over VPN and my IP address changed. In the conf/buildAgent.properties file, I changed my assigned IP for the serverURL property to use localhost instead, and the agent connected right up.

## The address of the TeamCity server. The same as is used to open 
TeamCity web interface in the browser.
#serverUrl=http://111.222.333.444:8111
serverUrl=http://localhost:8111


来源:https://stackoverflow.com/questions/12279081/teamcity-build-agent-disconnected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!