詹金斯:如何从TFS信息库构建多个项目? [英] Jenkins: How To Build multiple projects from a TFS repository?
问题描述
我已将工作空间目录设置为C:\jenkins_builds\workspace
,我想构建ProjA
和ProjB
,每个都具有本地工作文件夹(与项目名称相同).
I have set my workspace directory to C:\jenkins_builds\workspace
and I want to build ProjA
and ProjB
, each having a local workfolder (same as project name).
从我的存储库中获取源代码时,TFS插件要做的前两件事是:
When fetching the source code from my repository, the first two things the TFS plugin does are:
tf workspace -new %workspace-name-A%;%user-name% -server:%my-server%
tf workfold -map $%branch% ProjA -workspace:%workspace-name-A% -server:%my-server%
构建ProjA
时哪个很好.问题是,第一个命令将根目录从存储库直接映射到我的C:\jenkins_builds\workspace
目录.第二个命令执行我实际想要的操作,即将%branch%
映射到ProjA
子文件夹.稍后,在构建ProjB
时,第一个命令失败(因此构建失败),并显示以下错误消息:
Which goes fine when building ProjA
. The problem is, the first command maps the root directory from the repository directly to my C:\jenkins_builds\workspace
directory. The second command does what I actually want, i.e. mapping %branch%
to the ProjA
subfolder. Later on, when building ProjB
, the first command fails (and consequently the build) with the following error message:
The path C:\jenkins_builds\workspace is already mapped in workspace %workspace-name-A%;%user-name%.
好的,将根目录映射到工作目录似乎是个坏主意.但是,当TFS插件运行workspace new
行时,为什么会自动发生这种情况?当前,我必须通过运行-unmap命令来清理在ProjA
和ProjB
之间的构建.
OK, it seems like a bad idea to map the root directory to the work directory. But why does this automatically happen when the TFS plugin runs the workspace new
line? Currently I have to clean things up between building ProjA
and ProjB
by running the -unmap command.
我的团队正在使用Team Foundation 3.0.
My team is using Team Foundation 3.0.
推荐答案
我们的情况相同,有2种解决方法:
We have the same situation and there are 2 ways to solve this:
- 为两个版本使用不同的工作区根目录
这导致需要两次检出=>将空间加倍,并且速度较慢,但两个版本之间的隔离度更高 - 将两个构建的工作区名称硬编码"为相同
默认情况下,jenkins创建一个包含构建名称的工作空间,可以在TFS配置的高级"部分中对其进行更改,然后可以对多个构建使用相同的工作空间/工作文件夹映射-在本例中,我们将它们称为ProjectName_${NODE_NAME}
因此它甚至可以在多个节点上工作
- use different workspace-root-directories for the two builds
This results in the need for two checkouts => double the space and slower, but better isolation between the two builds - "hardcode" the workspace name to the same for both builds
By default jenkins creates a workspace containing the build name, which can be changed in the "advanced" section of the TFS config, and then you can use the same workspace-/workfolder-mapping for several builds - in our case we called themProjectName_${NODE_NAME}
so it even works on several nodes
这篇关于詹金斯:如何从TFS信息库构建多个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!