Version control (e.g. in TFS) build configuration

2019-06-20 20:49发布

问题:

I'm looking to migrate our build infrastructure from CC.NET to TeamCity. Admittedly pretty green with TeamCity at this point.

One potential show-stopper is that we need our build configuration to be version-controlled alongside the source code it builds. CC.NET makes this pretty easy and is a very useful/powerful feature.

From my investigation you can change where TeamCity stores its config/data, but none of the official documentation (nor other topics here on SO) seem to reference placing it in a version-controlled location such as TFS, Perforce or ClearCase.

I therefore wonder if it's possible and/or is it the 'done thing'??

Could it be that if TeamCity assumes R/W access to any config files and the underlying VCS makes files R/O requiring check-in/check-out semantics that this'll confuse TeamCity and stop it working.

Does anyone here have experience of version controlling TeamCity build configuration in Team Foundation Server (or similar)?

Thanks, Jack

FYI - How does one version control the configuration of a TeamCity project? seems to be the only similar thread here on SO. http://confluence.jetbrains.net/display/TCD7/How+To... and related official docs talk about migrating config and/or backing it up, which is close but not really the same thing.

回答1:

This isn't an answer, but...

We asked JetBrains for their recommendation on this and got the following response:

So far there is no functionality to store configuration settings in the version control. The settings are stored in XML on the disk (in TeamCity data directory - http://confluence.jetbrains.net/display/TCD7/TeamCity+Data+Directory) and in theory it is possible to synchronize the directory with a version control. You might want to vote for the feature or watch it in our issue tracker: http://youtrack.jetbrains.com/issue/TW-2806

I can't see any elegant solution, so would think that the best solution (least worst solution...) is to:

  1. Move complex build logic into MSBuild/Nant scripts that are version controlled; and
  2. If you have the time, implement a custom synchronisation service between your source control and the TeamCity data directory. In this case you will probably have to be prepared to deal with failures that will require manual merges from time to time (not fun :-( ).

Good luck, and if you find a good solution please share it :-D



回答2:

This has been introduced in TeamCity 9:

https://confluence.jetbrains.com/display/TCD9/Storing+Project+Settings+in+Version+Control



回答3:

I've been wanting a way to source control TeamCity config for a long time. I ended up writing a Windows Service which monitors the configuration directory and commits changes to git.

It isn't TFS but the source code is on GitHub so you could easily adapt the solution to fit your needs.

The project is on GitHub: https://github.com/grenade/teamcity-config-monitor



回答4:

As far as I know this isn't supported, but an approach I recommend is to invoke a batch file stored in source control during build. The batch file can manually invoke the commands required to do the build, or could invoke e.g. FinalBuilder. This allows for great flexibility in the build process.