Connect TeamCity to Visual Studio Online
Asked Answered
P

4

5

I'm trying to migrate from on-premises TFS to Visual Studio Online. We have quite elaborate TeamCity build process that we don't want to migrate away from, so having TeamCity working with VSO would be ideal.

I've created alternative user credentials (as per this article) and using these credentials in TeamCity. But when I create new VCS in TeamCity, I get connection error:

TF30063: You are not authorized to access https://myproject.visualstudio.com/DefaultCollection/MyProject

I've tried my actual credentials (not alternative ones) but nothing changed - same error.

Also I've tried using alternative credentials with tf command line tool and could not enter alternative credentials - a window popped up, asking me for my LiveId.

Any idea how to fix this?

p.s. this is how TeamCity configuration look like:

enter image description here

Perished answered 23/6, 2014 at 11:52 Comment(7)
Try: https://myproject.visualstudio.com/DefaultCollection/ instead of adding the project name. Then in the source control paths use $/ProjectName/Path/To/File.Grout
Also make sure you enter the credentials correctly, see: https://mcmap.net/q/1640643/-connecting-teamcity-to-tfs-duplicate and confluence.jetbrains.com/display/TCD8/Team+Foundation+Server.Grout
That is TFS project, no Git involved. And I did try both paths with https://....com/defaultcollection/$projectname/ and without /$projectnam - no differencePerished
It must be without the project name in the URI. You're connecting to the Project Collection in TFS, not to the Team Project directly. Can you post a screenshot of your alternate credentials and your VCS root settings?Grout
@Grout posted screenshot, but don't think this is the issue. I had VS updates missing, so getting them installed.Perished
Have you tried setting the alternate credential name to match your live id? Last time I tried it didn't work when I used a different name there.Grout
@Grout Yep, tried my actual username with alternative password and all other possible combinations of usernames/passwords. No luck.Perished
G
5

To connect to Visual Studio Online you indeed need to enable alternate credentials on the account you'll use for Team City. Ensure that at least Team Explorer 2012 and update 4 is installed on the Team City server, install the whole Visual Studio 2012 incl Update 4. Team City requires at least update 2, but Microsoft only supports Visual Studio 2012 RTM and the latest update (which is update 4).

Then in the connection screen use the following information: enter image description here

Repository URL: https://myaccount.visualstudio.com/DefaultCollection

Username: ##LIVEID##\[email protected] // Your visual Studio Online User Name, must match your LiveId.

Password: ********* // The password you setup for the alternate credentials.

You can also use the VSO Service Account credentials instead of using Alternate Credentials.

Then in your VCS Root configuration map your TFVC root in the following way:

Root: $/MyProject/Path/To/Branch/Root

Check out this post on the Jetbrains Confluence site for more details.

Grout answered 23/6, 2014 at 12:47 Comment(6)
I did miss "##LIVE##\" prefix, but with it it still does not work. I have noticed that Jetbrains requires "Visual Studio 2012 Update 1", which is not installed at the moment. Probably this is the issue. I'll get it installed overnight and will report back. Thanks for help so far.Perished
Since Microsoft only supports the latest update version of Visual Studio, I suggest installing Visual Studio 2012 update 4.Grout
Yep, could not get update 1, so installing VS2012 Update 4 as we speak.Perished
After update to VS2012.4 I managed to connect to VSO successfully. Thank you for your help!Perished
It would be better to use the service account credentials rather than a users credentials. You can get this by using the TFS Credential Viewer: nakedalm.com/…Thetos
This is great. My only issue was that my TC server had Team Explorer 2012 on it, when I installed what I thought was VS2012 with Update 4, it was actually just "Update 4" and it updated Team Explorer. In the end, it still worked and I didn't need the full VS2012 to make it happen. Thanks!Indochina
W
2

This has changed lately and the password needs to be generated.

Navigate to your site at https://[your project].visualstudio.com/_details/security/tokens And generate a personal access token. And use it for password in your teamcity vcs root configuration. Username is your email.

https://streamlined.no/2016/09/19/connecting-teamcity-10-vcs-root-visual-studio-team-services/

Note: TeamCity 10 does not need the ##LIVE## workaround anymore.

Wexler answered 19/9, 2016 at 13:38 Comment(1)
This worked for me. I was using the "Alternate Authentication Credentials" when the server suddenly had an error connecting with this. Switched to using a generated Personal access token and got everything working again. Still no idea why the other connection suddenly started failing as we made no changes to the environment since our last successful connection/build.Thrasher
V
0

I had the same problem today. The TC instance which was working fine last week mysteriously could not connect to any VCS Roots after the weekend. All VCS roots are git repos in visual studio online.

The Test Connection was failing and changing to known working user accounts still failed.

Restarting the TC service also had no impact on the problem. In the end, rebooting the whole TC Server fixed the issue. Hopefully this will help someone else out.

Valkyrie answered 14/8, 2017 at 10:22 Comment(0)
I
0

Well, I could not use Alternate credentials as I use it in many build configurations and it was set up to poll every 60 seconds. So I had to do much manual work to fix it up. Instead, I generated a Personal Access Token and in the Team City VCS setup for Git I entered "username" as the username and pasted the PAT into the password. That worked much better and more stable than Alternate credentials, which kept getting disabled because of background polling on behalf of Team City.

Idiotic answered 13/11, 2019 at 17:42 Comment(1)
There were no PAT 5 years ago when I had this problem.Perished

© 2022 - 2024 — McMap. All rights reserved.