4

I have a project that uses SVN externals to include some stuff (actually it's the MSBuild Community Tasks, but that's tangential). The external repository requires a username 'guest' but no password.

I've set an externals property and this works perfectly when doing an SVN Update locally. The problem comes when my TeamCity continuous integration build runs. TeamCity tries to checkout the sources and chokes on the externals, because it doesn't know the username.

I've tried defining the externals as a separate SVN root in TeamCity, but that doesn't work so I don't think it is the solution.

So how do I make this work? How do I let TeamCity know that it needs to log in to the external SVN repo?

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
Tim Long
  • 13,508
  • 19
  • 79
  • 147
  • I actually solved the problem in the end by simply importing the external stuff into my repository. It was a small amount of stuff and that was just the simplest approach, but it goes against the grain having to do this. – Tim Long Aug 12 '09 at 02:16
  • UPDATE: 4 years down the line and this question is now completely irrelevant. We now use GIT for version control, and NuGet to manage 3rd party dependencies. If there isn't a NuGet package for something, we create our own and publish it from our TeamCity server. So much has changed in such a short time! It's an exciting time to be a software engineer. – Tim Long Nov 11 '13 at 17:30

5 Answers5

4

If no password is required, only a username then you can easily set this up in the servers config file (on Windows, it's located in %APPDATA%\Subversion\servers).

Specify the server and then set the 'username' option. For example:

[groups]
communitytasks = *.comunityserver.com

[communitytasks]
username = guest
sam hocevar
  • 11,853
  • 5
  • 49
  • 68
Stefan
  • 43,293
  • 10
  • 75
  • 117
  • Let me see if I understand this correctly. You;re saying that I need to do this on _my_ SVN server, even though the externals are on someone else's server? I may be misunderstanding how externals work. I was thinking that the client checked out the externals, but what you are suggesting is that the _server_ goes out and gets the externals, is that correct? – Tim Long Aug 12 '09 at 02:18
  • No, it's not the server that gets the externals. But there's a 'servers' file used by svn *clients* too - that's where all the network stuff is configured and how to access those. And since the client accesses the externals, you have to configure it there. – Stefan Aug 12 '09 at 08:58
  • I have the exact same problem (except I do need to specify a password). I looked at the servers file but I only see options for setting a proxy username and password. How can you specify a repository username and password? – Zack Jan 07 '10 at 19:52
2

Authentication information is stored in a configuration file local to the user running the program. Or at least, it can be configured to do that.

I bet TeamCity's Agent program runs under a different user than the one you log into the machine with. If it does, you should try just logging into the machine with the same user, then do a svn checkout to a temporary directory and fill in the username and password. This will be cached, and thus when TeamCity runs SVN under the same user, it should reuse that information.

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • That's one way I guess, but it doesn't seem very robust. I would have to do that on every build agent for every external reference, for example. Plus, the cached credentials might get cleaned up, etc. I was really hoping maybe there was a way to do this declaratively, in a settings or configuration file. – Tim Long Aug 08 '09 at 14:37
2

TeamCity uses cached authentication information from SVN client to access externals. There is no other way to specify externals authentication information other than access remote server from command line client, cache credentials locally, and have TeamCity use them (in TeamCity SVN settings there is a checkbox whether to use stored SVN settings)

KIR
  • 5,614
  • 1
  • 31
  • 23
1

Not specific to TeamCity, but if you need to specify which username to use when checking out an svn:externals repository:

In the svn:externals property, don't specify a username:

the_vendor_dir     svn+ssh://hostname/path/to/repo

By default, checkouts will then use the current user's username. To use a different username:

~/.subversion/config:
[tunnels]
ssh = $SVN_SSH ssh -ljdoe

That will cause Subversion to use jdoe as the username for any svn+ssh tunnel that doesn't specify a username.

Instead of changing the svn+ssh tunnel at the Subversion level, you could also change it at the SSH level:

~/.ssh/config:
Host svn.example.com
   User jdoe

Stefan's answer above about ~/.subversion/servers didn't work for me, and doesn't seem like it should work since the username setting is not a documented in that file.

Animism
  • 496
  • 4
  • 10
0

I've never used TeamCity, but have used other CI tools.

Instead of having TeamCity poll the svn repo for new revisions. Maybe have a post commit hook invoke TeamCity, but prior to doing so, have it run an ant script that svn updates a directory local to the TeamCity server. First time you checkout to this directory you should have the opportunity to set externals.

Phillip Jacobs
  • 168
  • 2
  • 6
  • Thanks for the suggestions, but I think that's too messy and would short-circuit a lot of the nice features that TeamCity has around VCS integration and build triggering. Plus, the build agents run on different boxes to the TeamCity server so checking out to a hard-coded directory probably will not be very maintainable. I'm trying to reduce dependencies of fixed locations as much as possible. – Tim Long Aug 12 '09 at 02:24