I am trying to get a specific assembly from TFS, but it is complicated. I have an MVC application that runs a build like this:
IBuildServer buildServer = (IBuildServer)Server.GetService(typeof(IBuildServer)); IBuildDefinition def = buildServer.GetBuildDefinition(TeamProject, BuildDefinition); var queuedBuild = buildServer.QueueBuild(def);
QueueBuild returns IQueuedBuild, and I was hoping to do something like this:
return queuedBuild.Build.BuildNumber
So, I will have some unique value that I could use to query the build server to get the correct build. Unfortunately, Build may or may not be null when execution completes this method, so this is not an option.
After assembling in the queue, I then poll this method
public string GetBuildStatus(string TeamProject, string BuildDefinition, string BuildNumber) { string status = string.Empty; IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(TeamProject, BuildDefinition); buildDetailSpec.MaxBuildsPerDefinition = 1; buildDetailSpec.Status = BuildStatus.InProgress | BuildStatus.None; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; IBuildQueryResult queryResult = buildServer.QueryBuilds(buildDetailSpec); if (queryResult.Builds.Length > 0) { status = queryResult.Builds[0].Status.ToString(); } return status; }
This works to some extent, but if there are several assemblies in the queue, I cannot know in this polling method if the assembly I am working with is the one I queued in the first method. Does anyone know what I can do to return a specific assembly that is queued in the first method?
Thanks!
source share