Connect TeamCity to Visual Studio Online

2020-02-06 07:36发布

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

4条回答
Fickle 薄情
2楼-- · 2020-02-06 07:58

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.

查看更多
闹够了就滚
3楼-- · 2020-02-06 08:13

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##\your.email@live.com // 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.

查看更多
虎瘦雄心在
4楼-- · 2020-02-06 08:18

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.

查看更多
倾城 Initia
5楼-- · 2020-02-06 08:19

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.

查看更多
登录 后发表回答