Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you pull multiple TFS repos into a single Jenkins job?

I have a repo that has 2 subfolders $/Repo/project and $/Repo/thirdparty. I need to pull both of those into Jenkins for a single build. Naturally I tried just pulling $/Repo, but this gives me a bunch of other projects along with false polls (it will build every time ANYTHING is checked into $/Repo). I have tried using the multi-scm plugin which works, but does not save the configuration (annoying, but not unusable). I tried using the regular tfs plugin and manually putting the calls for the other repo into a windows command (this did not work even through i bound them them to different folders).

What is the best way to approach this? Some sort of subjob that pulls third party? Fix the multiple scm plugin? Is there some tfs command or trigger to pull a different repo when you pull a project?

like image 441
Tyler Smith Avatar asked May 03 '12 12:05

Tyler Smith


2 Answers

I was able to get this working with a job pipeline. It's kinda hacky, but it works.

The program I'm trying to build uses $/Department/Framework/Main (as workspace\Framework), and $/Department/Products/TheProgram/Main (as workspace\TheProgram).

I created three jobs in Jenkins, each "downstream" of the other:

  • Framework-Get: normal source code triggering on TFS' Project Path of $/Department/Framework/Main. No build step.
  • TheProgram-Get: normal source code triggering on TFS' Product Path of $/Department/Products/TheProgram. No build step.
  • TheProgram-Build: No source code control. But the build steps xcopy's the source from the above two steps. Then, you can run a normal build step.

TheProgram-Build's first build step is a windows batch command:

REM ====================================
REM First Get the Framework folder:
rmdir /s/q Framework
mkdir Framework
xcopy /y /q /e ..\..\Framework-Get\Workspace\Framework Framework

REM ====================================
REM Then Get the TheProgram Folder:
rmdir /s/q TheProgram 
mkdir TheProgram 
xcopy /y /q /e ..\..\TheProgram-Get\Workspace\TheProgram TheProgram

The second build step was a simple call to ant. But you could use msbuild or whatever you like here.

like image 68
Brian Shelden Avatar answered Sep 28 '22 00:09

Brian Shelden


The TFS pluging for Jenkins currently does not support checking out the sources from multiple locations. multiple-scm-plugin might be the answer, but as You pointed out in the question - it's really not an option at this point. There are really, as far I can see it, only to possible solutions for you to test out:

  1. Create a workspace within TFS that will include all the neccesary imports. I use this functionality in my every-day encounters with TFS, although I have never a chance to use that with Jenkins plugin. It might work, it might not.
  2. You can use, and please - this is a quite serious option, at least for me - git. There is a git-tfs and import all of the required projects into git repository. And having them in git will open a bunch of possibilities for you, including using separate repos for every folder, using git modules, git externals... and so on. So, at least for me, it is a valid option, although it seems like an ugly workaround at the first look...
like image 43
Łukasz Rżanek Avatar answered Sep 27 '22 23:09

Łukasz Rżanek