2
votes

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
For what it's worth, it's not the workspace -new line that's causing this, it's the second line which creates a working folder mapping. Working folder mappings must be unique for a server path inside a workspace. - Edward Thomson
Edward, thank you for your feedback. That's what I initially thought. The second line creates the mapping between the branch name and the project subfolder (as one might think). However, after running the commands from the command prompt, it turns out the first one actually maps the working folder "C:\jenkins_builds\workspace" with "$/" in the TFS repository. Quite counter-intuitive, right? This is what causes my head-ache. - user1160298

1 Answers

1
votes

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