12

Installed the tfs 2017 (update 1) build agent on a machine and ran config.cmd to connect it to a TFS server. That server had to be reconfigured and the original url that the build agent was pointing to is no longer valid. All I want to do is reconfigure the build agent to connect using the new url. When I run config.cmd again, it says that I must first call 'config.cmd remove' but when I run that, it fails because it is trying to reach out to the original url to remove itself from the agent pool.

How can I force it to uninstall so that I can configure a new one? I have even deleted the whole agent directory, re-extracted from zip, and tried again but it's detecting that it's configured from somewhere else.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Tom
  • 1,179
  • 12
  • 28

1 Answers1

19

Delete/rename the .agent file and then try to unconfigure:

C:\TfsData\jessehouwing>config.cmd remove
Removing service
Waiting for service to stop...
Failed: Removing service
Could not find file 'C:\TfsData\jessehouwing\.agent'.

C:\TfsData\jessehouwing>config.cmd remove
Removing service
Succeeded: Removing service
Removing agent from the server
Cannot connect to server, because config files are missing. Skipping removing agent from the server.
Removing .credentials
Succeeded: Removing .credentials
Removing .agent
Does not exist. Skipping Removing .agent
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • This worked great. I am actually pretty annoyed at myself because I didn't see those files at all. I was RDP'd in and didn't realize the show hidden files was turned off. When I deleted everything and tried again, I only did a select all in the dir and deleted instead of deleting the whole agent folder because I was going to be extracting right back into the directory. Actually semi-embarassed I missed this but thanks so much for the quick response! – Tom Mar 22 '17 at 21:06
  • 1
    Thanks for this. I used this to move agents to another file location. When done the builds failed until I deleted the associated workspace with the tf command i.e. tf workspace /collection:{collection} /delete {workspacename};{workspacecollection}. Cheers – Crab Bucket Nov 22 '17 at 22:31
  • As a note, I had to run `remove-item .\.agent -recurse -force` to remove the config file, even in Admin powershell. – Sators Jan 01 '21 at 15:47