Pierre
Pierre

Reputation: 330

TFS Build 2013 drop location

I have 6 build servers and multiple build definitions. I want the drop location to be C:\Builds\BuildDefinition.Name\BuildNumber. If I set the drop location to \\localhost\Builds, the files are dropped at the correct location, but I cannot access the drop location from Visual Studio (I suppose it's looking at \\localhost on my local machine then).

The build definitions aren't built by one specific build server, you usually pick the one that isn't busy, so I can't hard code the drop location to, say, \\BuildServer1\Builds.

How do I go about having the drop location be \\SelectedBuildServer\Builds\, so that it changes depending on which build server I queue the build on?

I don't want to have a set network location for drops, because the drops are >1gb in file size, so it takes quite some time. I want the drops to be locally on the build server that they were built on.

SOLUTION:

BuildDetail.DropLocation = "\\"
+ BuildDetail.BuildController.Name 
+ "\Builds\" 
+ BuildDetail.BuildDefinition.Name 
+ "\" + BuildDetail.BuildNumber + "\"

Works out to: \\BuildServerNetworkLocation\Builds\BuildDefinitionName\BuildNumber

My controller name is the same as my Build Server network location.

Upvotes: 1

Views: 270

Answers (1)

Mike
Mike

Reputation: 2510

You're going to have to edit the build template (.xaml), unless you want to go the pre/post-build powershell script route (don't know if that would work though).

A good spot (assuming you're using the default TfvcTemplate.12) would be just after the "Associate the changesets that occurred since the last good build" step.

You need to add a step to use GetBuildAgent to get a buildAgent instance and/or GetBuildDetail for a buildDetail - I honestly cannot remember which contains the build server ID, though you can parse it out of...

buildAgent.GetExpandedBuildDirectory(buildDetail.BuildDefinition)

...if you're desperate. After that you should be able to append the value to the...

buildDetail.DropLocation 

...property and I think that'll do it for you.

I'm away from the build server just now but if you get stuck just should and I'll see what I can find.

Edit: sorry, just saw the bit about the build name also being wanted. I believe you should be able to get that from the same object as the build server id.

Upvotes: 1

Related Questions