Reputation: 1471
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?
Upvotes: 0
Views: 163
Reputation: 33738
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.
Upvotes: 1