Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity Build Agent won't upgrade

We are trying to setup a build agent and every time we start it the log shows the following messages:

[2012-09-18 12:52:01,805]   INFO -    jetbrains.buildServer.AGENT - Starting agent shutdown sequence, reason: Restart agent, failed to download upgrade from server 
[2012-09-18 12:52:01,821]   INFO -    jetbrains.buildServer.AGENT - Host configuration for downloading updates: HostConfiguration[host=http://localhost:8000] 
[2012-09-18 12:52:01,821]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/teamcity-agent.xml ==> E:\buildAgent\temp\m8a1mAwTuLIngev3yRUMPUuaYWZFmMSh 
[2012-09-18 12:52:01,849]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/agentSystemInfo.zip ==> E:\buildAgent\update\plugins\agentSystemInfo.zip 
[2012-09-18 12:52:01,880]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/amazonEC2.zip ==> E:\buildAgent\update\plugins\amazonEC2.zip 
[2012-09-18 12:52:01,921]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/ant.zip ==> E:\buildAgent\update\plugins\ant.zip 
[2012-09-18 12:52:02,056]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/antPlugin.zip ==> E:\buildAgent\update\plugins\antPlugin.zip 
[2012-09-18 12:52:02,078]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/assembly-info-patcher.zip ==> E:\buildAgent\update\plugins\assembly-info-patcher.zip 
[2012-09-18 12:52:02,098]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/clearcase-agent.zip ==> E:\buildAgent\update\plugins\clearcase-agent.zip 
[2012-09-18 12:52:02,106]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/commandLineRunner.jar ==> E:\buildAgent\update\plugins\commandLineRunner.jar 
[2012-09-18 12:52:02,118]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/coveragePlugin.zip ==> E:\buildAgent\update\plugins\coveragePlugin.zip 
[2012-09-18 12:52:02,151]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/crashDetector.zip ==> E:\buildAgent\update\plugins\crashDetector.zip 
[2012-09-18 12:52:02,163]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/cvsAgent.zip ==> E:\buildAgent\update\plugins\cvsAgent.zip 
[2012-09-18 12:52:02,183]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/dotCover.zip ==> E:\buildAgent\update\plugins\dotCover.zip 
[2012-09-18 12:52:02,308]   INFO -    jetbrains.buildServer.AGENT - Downloading http://localhost:8000/update/plugins/dotNetPlugin.zip ==> E:\buildAgent\update\plugins\dotNetPlugin.zip 
[2012-09-18 12:52:03,830]   INFO - agent.impl.AgentPortFileWriter - Delete agent runtime file from E:\buildAgent\logs\buildAgent.port 
[2012-09-18 12:52:03,831]   INFO -    jetbrains.buildServer.AGENT - Unregistering from build server: 5 

Has anyone seen anything like this before? We've looked at the server logs and aren't seeing anything on them to indicate what could be wrong.

like image 636
Shane Courtrille Avatar asked Sep 18 '12 18:09

Shane Courtrille


People also ask

How do I add a build agent in TeamCity?

Open the Agents page in TeamCity. Click Install Build Agents and select Windows Installer to download the installer. On the agent machine, run agentInstaller.exe and follow the installation instructions.

Is TeamCity vulnerable to log4j?

TeamCity core uses log4j 1.2 which is not vulnerable. To confirm its safety we have run additional tests through the known attack vectors which did not replicate the issue.


2 Answers

I ran into the same issue. Both the build agent and the server are installed on Windows Server 2012.

I stopped the build agent service and deleted the logs from BuildAgent\logs and restarted the build agent service so I could see a fresh log.

upgrade.log showed me that the build agent received a call from the teamcity server to upgrade. The log also showed the following:

"Please check TeamCity build agent service user have enough permissions to stop and start the service."

Using the Local Security Policy, I granted the build agent service user "logon as a service" rights but this is not sufficient to start and stop a service. By default, only members of the Administrators group can start, stop, pause, resume or restart a service. After I added the build agent service user to the Administrator group and restarted the build agent service, the upgrade finished successfully and the agent connected again.

Alternatively, as described by BatteryBackupUnit and https://web.archive.org/web/20171019005501/http://windowsitpro.com/security/letting-user-start-and-stop-services-without-granting-user-administrator-privileges, it's possible to give the TeamCity Windows user account the start, stop and pause permissions on the TeamCity Build Agent service. The article says that something like

subinacl /service spooler /grant=contoso\cortana=top

will suffice.

Or, if you don't want to use a tool that Microsoft no longer makes available, then you can use Process Explorer, as described at https://superuser.com/a/315709/12337.

like image 61
Frank Avatar answered Sep 21 '22 12:09

Frank


I had this problem when running the agent with systemd on Ubuntu 18.04. The agent exits with code 143 when upgrading and this is interpreted as an error. It needs to be added to the list of acceptable error codes with SuccessExitStatus=143 0

Here's the full configuration:

[Unit]
Description=TeamCity Build Agent
After=network.target

[Service]
Type=forking
RemainAfterExit=yes
PIDFile=/build-agent/logs/buildAgent.pid
ExecStart=/build-agent/bin/agent.sh start
ExecStop=/build-agent/bin/agent.sh stop
User=build
Group=build

Restart=on-failure
RestartSec=5s

# agent will exit with 143 during upgrade process
SuccessExitStatus=143 0

[Install]
WantedBy=multi-user.target
like image 43
Steve Rukuts Avatar answered Sep 22 '22 12:09

Steve Rukuts