0

I'm using TFS to edit a build deinition then queue it. I have everything I need to get the build server and the build itself. I can even queue a build, but I don't know how to specify an option when I do. The builds are Gated, and when I manually queue them, I have to specify "Latest Sources" when I do so, not "Latest Sources with Shelvesets" which seems to be the default.

Here is an example of what I'm clicking when I queue the build manually.

Below is what I have coded so far:

$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection("$serverURI")
$bs = $teamProjectCollection.GetService([type]"Microsoft.TeamFoundation.Build.Client.IBuildServer")
$build = $bs.GetBuildDefinition("$project", "$template")
#Here is where I would do all of the build editing, but it's not important.
$request = $definition.CreateBuildRequest()
$bs.QueueBuild($request, “None”) 

This code works, but I don't know how to specify the option of "Latest Sources" over the "Latest Sources with Shelveset". Can anyone help?

1
  • I would expect whether you specify $request.ShelvesetName or not will determine that (link) Commented Jul 25, 2016 at 19:25

1 Answer 1

1

Based on my test, it will build the project/solution with latest source if ShelvesetName is null, we can check the build log whether it builds the project with latest sources with shelveset (doesn’t contain information about shelveset if queue build with latest source).

For Gated Check-in build, the default option is latest sources with shelveset when we queue build through VS UI, but we must to specify shelveset name with latest sources with shelveset option, otherwise we can’t queue build. In other words, the shelveset name is required with latest source with shelveset option.

So, queue the build through TFS API, we just need to let ShelvesetName null to queue build with latest sources.

Sign up to request clarification or add additional context in comments.

1 Comment

So basically, if I don't specify, it'll default to just "Latest Sources" and not with a Shelveset? If that's what you mean, that should be pretty easy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.