1

I have three builds.

  • Build A
  • Build B (cloned from A)
  • Build C (cloned from B)

Build A builds our entire environment, Builds B and C were cloned, but then stripped to only build specific parts and from different branches. Since doing this, we've seen the build time on Build A triple. It is running tf vc workspace /delete on every build.

Build C also deletes it's workspace, but build B does NOT. On the repository tab, all three have Clean set to false.

Is there anywhere to view/set options for the Get Sources task? What would cause one build not to do this and the other two to do it?

MitchelWB
  • 619
  • 1
  • 7
  • 18
  • 1
    What version of TFS are you using? What is the output of the Get Sources task with `System.Debug` set to `true`? Do your workspace mappings have any leading space characters? I've identified a bug around TFVC workspace mappings in TFS 2018 (and possibly TFS 2017) if a leading space is present in the workspace mappings. – Daniel Mann Apr 27 '18 at 17:45
  • We are on 2017 Release 1. Setting the debug to true did shine a little more light on the subject. It appears to be searching for a particular workspace and when it finds it, the mappings are off: "Expected number of mappings: '48'. Actual: '44'" I ran a build with clean=true to try and clear the mappings, then again with it set to false again but it's still off. So I guess I need to look at the Repository to see if there's something wrong? In the example I gave originally, the Build B has had a large number of repositories removed so I guess that should have been a clue too. – MitchelWB Apr 30 '18 at 02:07

2 Answers2

3

There are only three TFVC options in get source step of TFS build pipeline.

enter image description here

No any other extra option to control the get source task.

First suggest you check whether you set Clean = true in Visual Studio Build task, you need to uncheck it here.

enter image description here

If you do not check Clean option and the build always refreshed workspace on local build server and build agent always cleans TFVC Repository. Try this solution: completely wipe the agent directory and start again, this may fix the problem. Another way is reconfigure your build agent and trigger the build again.

Besides, you could also disable the default get source steps in the build definition. And use your own script to do the get source/pull files to bypass workspace mapping issue. How to, please follow: Is it able to ignore/disable the first step Get source in vNext Build?

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I'm not necessarily looking to remove or replace the Get Tasks. I'm just trying to understand why it's always doing a workspace delete even though it already exists. With system.debug = true I'm seeing more information, including what appears to be an unnamed XML document that defines the workspaces. It's checking there first but when it doesn't match what it wants, it wipes the workspace and gets all. I don't know why it's not updating the XML when I set clean=true on the repository. – MitchelWB Apr 30 '18 at 13:03
  • @MitchelWB Seems to be a mapping issue. Thanks for the sharing below, glad to hear the issue fixed. Always better when you fix yourself, as you could know how it works. You could mark your reply as answer, which will also help others in the community. – PatrickLu-MSFT May 01 '18 at 05:46
1

I found my answer. By adding the System.debug = true I was able to get a view of the actual mappings in the workspace. Then I matched that up against a list of all the mappings in the repository of the build. What I found was that when we map a folder and one of its sub-folders as well, only the parent folder mapping is created in the workspace definition.

When Get Sources runs, it looks for a workspace name that matches and then first does a simple count check. When the number of mappings in the repository doesn't match the number of mappings in the workspace it fails out and immediately deletes and rebuilds the workspace.

By removing the sub-folder mappings, my Get Sources task dropped from 11+ minutes to seconds.

MitchelWB
  • 619
  • 1
  • 7
  • 18