How to get build definitions using TFS-API given collection-guid and project-name
Please refer here for more details. This is one of the best resources on TFS stuff.
private TfsConfigurationServer configurationServer;
configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri);
public IList<KeyValuePair<string, Uri>> GetBuildDefinitionListFromProject(Guid collectionId, string projectName)
{
List<IBuildDefinition> buildDefinitionList = null;
List<KeyValuePair<string, Uri>> buildDefinitionInfoList = null;
try
{
buildDefinitionInfoList = new List<KeyValuePair<string, Uri>>();
TfsTeamProjectCollection tfsProjectCollection =
configurationServer.GetTeamProjectCollection(collectionId);
tfsProjectCollection.Authenticate();
var buildServer = (IBuildServer)tfsProjectCollection.GetService(typeof(IBuildServer));
buildDefinitionList = new List<IBuildDefinition>(buildServer.QueryBuildDefinitions(projectName));
}
catch (Exception e)
{
ApplicationLogger.Log(e);
}
if (buildDefinitionList != null && buildDefinitionList.Count > 0)
{
foreach (IBuildDefinition builddef in buildDefinitionList)
{
buildDefinitionInfoList.Add(new KeyValuePair<string, Uri>(builddef.Name, builddef.Uri));
}
}
return buildDefinitionInfoList;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With