Jenkins: How To Build multiple projects from a TFS

2019-07-23 14:23发布

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

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%

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

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.

My team is using Team Foundation 3.0.

1条回答
家丑人穷心不美
2楼-- · 2019-07-23 15:20

We have the same situation and there are 2 ways to solve this:

  • 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 them ProjectName_${NODE_NAME} so it even works on several nodes
查看更多
登录 后发表回答