Connecting TeamCity to TFS [duplicate]
Asked Answered
O

3

6

I'm struggling trying to connect my TeamCity project to my TFS project. I tried a bunch of stuff, but I always get the same error:

TFS failed. ExitCode: 111, command: C:\TeamCity\webapps\ROOT\WEB-INF\plugins\tfs\bin\tfs-native.exe @@C:\TeamCity\temp\TC-TFS-25-7939_109\command.params, in file: {https://budiedimas.visualstudio.com/DefaultCollection/TesteTeamCity, /hash:S, /noProxy, C:\TeamCity\temp\TC-TFS-25-7939_108.result, ConnectionTest, $/TesteTeamCity/TesteTeamCity}, completed in: 1 second(s)
stdout: TFS Native Verifier v8.0 Copyright (C) 2006-2013 JetBrains s.r.o.
Running under .NET Framework 4.0.30319.18052
INFO  - 
INFO  - Use Team Explorer 2012
INFO  - 
TFS Native Accessor v8.0 Copyright (C) 2006-2013 JetBrains s.r.o.
INFO  - Connecting to server https://budiedimas.visualstudio.com/DefaultCollection/TesteTeamCity
INFO  - WebProxy is disabled
Connection test:
  Server='https://budiedimas.visualstudio.com/DefaultCollection/TesteTeamCity'
  Root='$/TesteTeamCity/TesteTeamCity'
ERROR - TF30063: You are not authorized to access https://budiedimas.visualstudio.com/DefaultCollection/TesteTeamCity.
System.Exception: TF30063: You are not authorized to access https://budiedimas.visualstudio.com/DefaultCollection/TesteTeamCity. ---> Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: You are not authorized to access https://budiedimas.visualstudio.com/DefaultCollection/TesteTeamCity.
   em Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.EnsureTokenProvider(HttpWebResponse webResponse)
   em Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest()
   em Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout)
   em Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
   em Microsoft.TeamFoundation.Framework.Client.Registration.GetRegistrationEntries(String toolId)
   em Microsoft.TeamFoundation.Framework.Client.RegistrationProxy.GetRegistrationEntries(String toolId)
   em Microsoft.TeamFoundation.Framework.Client.RegistrationService.GetInstanceId()
   em Microsoft.TeamFoundation.Framework.Client.RegistrationService.get_InstanceClientCacheDirectory()
   em Microsoft.TeamFoundation.Framework.Client.RegistrationService..ctor(TfsTeamProjectCollection tfsObject)
   em Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.CreateServiceProxy(Type serviceType)
   em Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.GetServiceInstance(Type serviceType, Object serviceInstance)
   em Microsoft.TeamFoundation.Client.TfsConnection.GetService(Type serviceType)
   em Microsoft.TeamFoundation.Framework.Client.PreFrameworkServerDataProvider.FindServiceLocation(String serviceType, String toolId)
   em Microsoft.TeamFoundation.Framework.Client.PreFrameworkServerDataProvider.LocationForCurrentConnection(String serviceType, Guid serviceIdentifier)
   em Microsoft.TeamFoundation.Client.TfsConnection.EnsureProviderConnected()
   em JetBrains.TeamCity.Tfs.Command.Do() na c:\BuildAgent\work\23f504c63c17dfdf\TfsNativeAccessor\src\Command.cs:linha 28
   em JetBrains.TeamCity.Tfs.Program.Main(String[] args) na c:\BuildAgent\work\23f504c63c17dfdf\TfsNativeAccessor\src\Program.cs:linha 134
   --- Fim do rastreamento de pilha de exce‡äes internas ---
   em JetBrains.TeamCity.Tfs.Program.Main(String[] args) na c:\BuildAgent\work\23f504c63c17dfdf\TfsNativeAccessor\src\Program.cs:linha 438

I always get the error:

'You are not authorized to access /DefaultCollection/'

I have admin rights in everything on the TFS and I don't know if I'm missing some authorizantion configuration on the TeamCity.

Does anyone have any idea why this is happening?

Overcash answered 26/8, 2013 at 14:48 Comment(3)
Did you enable alternate credentials? blogs.msdn.com/b/buckh/archive/2013/01/07/…Ethmoid
Yes... I did.. Still gives the same problemOvercash
Hi Victor, I'm having exactly the same problem. Did you ever solve this?Tomasatomasina
T
12

I finally managed to get this working in the latest version of teamcity (which for me is 8.0.3) but apparently this has been working since version 7.1.4.

  1. First configure alternate credentials in TFS (profile -> credentials -> enable alternate credentials)

  2. Then in TeamCity

    • Use the following URL format: https://{yournamehere}.visualstudio.com/DefaultCollection
    • For the username use the alternate credential name you setup in step 1. BUT put it in the following format "##LIVE##\usernamehere" (It actually tells you this below the box, but I somehow missed it first time!)

Hope this helps someone else, as I wasted quite a bit of time on this!

Tomasatomasina answered 9/9, 2013 at 9:27 Comment(4)
In addition, don't forget to install Visual Studio Update 1 (or above). It's listed as a requirement in the instruction box Rob mentioned.Carillo
Does the admin of the Hosted TFS have to enter their credentials?Hin
Worked like a charm! Thanks! It might've helped if I read that info below the textbox in TeamCity, too.Gratify
The reason you need VS 2012 Update 1 or above is because the API used to connect to TFS was only added in 2012 Update 1 (source: youtrack.jetbrains.com/issue/TW-20909#)Protomartyr
P
2

I've blurred out my url name and username, but I know pictures help a lot of people. This is @Rob Birds solution to the problem. I can't thank him enough! Again, ensure you have at least VisualStudio 2012 Update 1 with Team Explorer installed on the TeamCity build server and agent. After updating Visual Studio (if needed), you'll need to restart the TeamCity build server and build agent as well.

enter image description here

Protomartyr answered 4/9, 2014 at 19:47 Comment(2)
+1 Always helps to have a picture - Nice one Jasper!Tomasatomasina
In addition, I requested an update to their documentation and they followed up with the changes very quickly. confluence.jetbrains.com/display/TCD8/… I love the JetBrains team.Protomartyr
S
0

Looks like its a cache issue. Restarting the Team city service worked for me

Seaton answered 12/3, 2014 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.