6

Looks like TFS supports only one repository per build. It is not enough for me as soon as I need to use some 3rd party libraries stored separately.

I can use GIT submodule for this, but in this case the build will not be associated with commits and work items because it ignores commits from submodules. Besides, a change in submodule will not trigger the build.

Is it possible to define a build with multiple repositories using plugins, extensions or something like that?

Eugene
  • 3,335
  • 3
  • 36
  • 44

2 Answers2

6

As @jessehouwing mentioned there is no way to build multiple GIT repositories by default. @jessehouwing and @Giulio Vian have provided some workarounds here:

  1. Use Nuget or other Package Manager to store the 3rd party libraries, and add a NuGet restore task to restore the libraries.

  2. Add Command Line task to call git.exe to pull the additional repositories.

  3. Create two build definition, in the second build definition, you need to add a powershell task. In the powershell script, you can use TFS REST API to queue the first build definition.

But none of them will associate commits and work items in two repositories with one build. I found there is already a UserVoice at website below, you can vote it:

https://developercommunity.visualstudio.com/idea/365522/allow-tfs-build-to-depend-on-multiple-repositories.html

Eugene
  • 3,335
  • 3
  • 36
  • 44
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
4

No, this is currently not possible. Instead, it's recommended to have your 3rd party libraries built and stored in the Package Management feature (as a NuGet or npm package) and take a dependency on the package instead of the source. This will not associate work items on 3rd party dependencies though.

Of course, if you really want to, you could call git.exe from a powershell or batch script and fetch the additional repositories. This will not associate work items either though.

Crono
  • 10,211
  • 6
  • 43
  • 75
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • To complete the answer, you may have a 'proxy' build triggered by changes in the second repository, whose only action is to kick off the primary build using the REST API (https://www.visualstudio.com/en-us/docs/integrate/api/build/builds#queueabuild) – Giulio Vian Jan 13 '17 at 13:19
  • @Jesse, thanks for the answer. I have a NET wrapper for a native lib, which uses more than 20 others native libs as dependencies. It’s very inconvenient to build them all separately. And it doesn’t solve the problem. I can find a way to build the library with TFS, but it doesn’t make sense without automatically commit and work item association. There will be no difference with my current build server outside of TFS. – Eugene Jan 16 '17 at 02:06
  • @Giulio, thanks for the comment. I have looked at the REST API and didn’t find a way to add a build association. I could write a server-side plugin with some build subscription, get a commit, parse it with external GIT tool or library, but there is no way to associate a commit with the build. – Eugene Jan 16 '17 at 02:09