TFS: query for collections containing a special set of changes

I have several build definitions that run on the basis of a single branch in TFS (e.g. Main).

I would like to (somehow) query TFS to find all the assemblies containing the specific change set number that I am providing and return a list of name strings of the assemblies that contains TFS. Any application (VS extension, CLI application, winforms, whatever) will do.

Note: this is not a request "plz give me the code"; I am ready to dig it and seriously do it. Any pointers to documentation on how to request a database or SDK, or an example of how to request assemblies; just a place to start looking would be very helpful. Thanks.

+6
source share
2 answers

The following snippet scans all assembly definitions for all Team Project Collection and checks each assembly for association for the number of input change set:

using System; using System.Linq; using Microsoft.TeamFoundation.Build.Client; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; namespace FindChangesetInBuild { class Program { static void Main(string[] args) { TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs:8080/tfs/collectionName")); var versionControl = teamProjectCollection.GetService<VersionControlServer>(); var buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer)); var teamProjects = versionControl.GetAllTeamProjects(true); foreach (var teamProject in teamProjects) { var buildDefinitions = buildService.QueryBuildDefinitions(teamProject.Name); foreach (var buildDefinition in buildDefinitions) { var builds = buildService.QueryBuilds(buildDefinition); foreach (var buildDetail in builds) { var changesets = InformationNodeConverters.GetAssociatedChangesets(buildDetail); if (changesets.Any(changesetSummary => changesetSummary.ChangesetId == Convert.ToInt32(args[0]))) { Console.WriteLine("Changeset was build in "+buildDetail.BuildNumber); } } } } } } } 

Needless to say, this is a brute force attack.
You can refine the code by narrowing the list of buildDefinition , focus on specific teamProjects , etc. In any case, I can hardly imagine the above to be useful as it is!

Besides (obviously) MSDN , a great resource for the TFS-SDK is the Shai Raiten blog . For Build-Speficic examples, also check here and here for some possibly interesting SO posts.

+8
source

You can use this small DB query in TFS 2010 and simply substitute 90264 with your changeet id.

 USE Tfs_Warehouse go SELECT BuildName FROM DimBuild INNER JOIN FactBuildChangeset ON DimBuild.BuildSK = FactBuildChangeset.BuildSK WHERE FactBuildChangeset.ChangesetSK = 90264 
+2
source

Source: https://habr.com/ru/post/912437/


All Articles