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

让人想犯罪 __ 提交于 2020-01-21 07:00:09

问题


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?


回答1:


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...



回答2:


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.




回答3:


The TFS plugin supports the ability to cloak folders in your $\Repo that you are not interested in. Checkins to cloaked folders will not trigger a build. Unfortunately that may be a lot of folders and you are only interested in two - you would need to maintain the list of cloaked folders as new ones are added.

We avoid the TFS plugin and instead scripted the setup of our TFS workspaces via powershell step using the tfs commandline. Each build specifies the folders it wants and the script takes care to cloak/uncloak the remainder.




回答4:


My solution to this is to create two Jobs, one that just download your dependency and another to make the build.

In my case I managed the build with Maven properties, for example:

pom.xml

<properties>
  <my.dir>../MyDir</wsdl.dir>
</properties>

Jenkins Build

Goals clean package -U -Dmy.dir=${WORKSPACE}/../../another-build/workspace/MyDir



回答5:


I had to create a workaround myself for Jenkins. This was achieved using both TF and the powershell Snapin Microsoft.TeamFoundation.PowerShell.

Basically the workflow is as follows :

Get-TFsWorkspace (Powershell : To check for the workspace)

TF Workspace /new (To Create a workspace)

TF Workfold /unmap (use this to remove the default $/ mapping which is made during workspace creation)

TF Workfold /map (To map specific locations, ie $/Repo/project)

TF Scorch (to remove any artifacts if there are any)

TF Get (To get the code)

There may be other methods that people have, but this would allow you to use the tf Workfold /cloak functionality as well.

Cheers,

Hope this helps.




回答6:


Can confirm that that Multiple SCM 0.5 works with the Team Foundation Server plug-in 4.0

The polling does seem to break however.



来源:https://stackoverflow.com/questions/10431142/how-do-you-pull-multiple-tfs-repos-into-a-single-jenkins-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!