public static void Main(string[] args) { LogArguments(args); Uri projectCollectionUri = new Uri(args.ElementAt(0)); Guid projectCollectionId = Guid.Parse(args.ElementAt(1)); Guid requestedByUserId = Guid.Parse(args.ElementAt(2)); string artifactsFolder = Path.GetFullPath(args.ElementAt(3)); string emailSubject = args.ElementAt(4); string emailBody = args.ElementAt(5); Console.WriteLine("Project collection URI: " + projectCollectionUri); Console.WriteLine("Project collection id: " + projectCollectionId); Console.WriteLine("User identifier: " + requestedByUserId); Console.WriteLine("Artifacts folder: " + artifactsFolder); Console.WriteLine("Email subject: " + emailSubject); Console.WriteLine("Email body: " + emailBody); string tfsUriFromCollectionUri = projectCollectionUri.AbsoluteUri.Replace(projectCollectionUri.Segments.Last(), string.Empty); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(tfsUriFromCollectionUri)); TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(projectCollectionId); IIdentityManagementService identityServiceManager = teamProjectCollection.GetService <IIdentityManagementService>(); TeamFoundationIdentity[] tfsIdentities = identityServiceManager.ReadIdentities(new Guid[1] { requestedByUserId }, MembershipQuery.Direct); SendArtifacs(tfsIdentities, emailSubject, emailBody, artifactsFolder); }
private static void GetProjectsForServerV1(Uri serverUrl) { var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(serverUrl); // Get the catalog of team project collections var collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // List the team project collections foreach (var collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection var collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); var teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); // Print the name of the team project collection Console.WriteLine("Collection: " + teamProjectCollection.Name); // Get a catalog of team projects for the collection var projectNodes = collectionNode.QueryChildren( new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); // List the team projects in the collection foreach (var projectNode in projectNodes) { Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName); } } }
static void Main(string[] args) { // Connect to Team Foundation Server // Server is the name of the server that is running the application tier for Team Foundation. // Port is the port that Team Foundation uses. The default port is 8080. // VDir is the virtual path to the Team Foundation application. The default path is tfs. Uri tfsUri = (args.Length < 1) ? new Uri("http://pro-pggm-manoj:8080/tfs") : new Uri(args[0]); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNodes[0].Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); ClientObjectModel.UpdateChangeSetComments(teamProjectCollection, "Updated Thru Code"); ClientObjectModel.DisplayWorkItemsInConsole(teamProjectCollection); }
/// <summary> /// Lists all TFS collection from server, each collection can have project /// </summary> public void ListAllCollections() { try { TfsConfigurationServer server = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(_tfsAddress)); ReadOnlyCollection <CatalogNode> collectionNodes = server.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); foreach (CatalogNode node in collectionNodes) { Guid collectionId = new Guid(node.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = server.GetTeamProjectCollection(collectionId); Console.WriteLine("Collection: " + teamProjectCollection.Name); // TODO - temporary list all projects also here ReadOnlyCollection <CatalogNode> projectNodes = node.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); foreach (CatalogNode elem in projectNodes) { Console.WriteLine("Team project name is: " + elem.Resource.DisplayName); } } } catch (Exception ex) { // custom exception handling - TODO throw custom exception _logger.Error("Tfs conection error: " + ex.Message); throw; } }
public void ConnectToTFSServer(string ServerURL) { // Connect to Team Foundation Server // Server is the name of the server that is running the application tier for Team Foundation. // Port is the port that Team Foundation uses. The default port is 8080. // VDir is the virtual path to the Team Foundation application. The default path is tfs. Uri tfsUri = new Uri(ServerURL); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // List the team project collections foreach (CatalogNode collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); // Print the name of the team project collection Console.WriteLine("Collection: " + teamProjectCollection.Name); // Get a catalog of team projects for the collection ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren( new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); } }
public object GetTeamProjectCollection(object name) { if (name == null || name == Null.Value || name == Undefined.Value) { var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(m_tfsUri); tfs.Credentials = m_credentialsProvider.Credential; tfs.EnsureAuthenticated(); return(new TfsTeamProjectCollectionInstance(this.Engine.Object, tfs)); } var strName = TypeConverter.ToString(name); var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(m_tfsUri); configurationServer.Credentials = m_credentialsProvider.Credential; configurationServer.EnsureAuthenticated(); var catalogNode = configurationServer.CatalogNode; var tpcNodes = catalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); var teamProjectCollection = tpcNodes.FirstOrDefault(p => p.Resource.DisplayName == strName); if (teamProjectCollection == null) { return(Null.Value); } return(new TfsTeamProjectCollectionInstance(this.Engine.Object.InstancePrototype, configurationServer.GetTeamProjectCollection(teamProjectCollection.Resource.Identifier))); }
public ArrayInstance ListTeamProjectCollections() { var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(m_tfsUri); configurationServer.Credentials = m_credentialsProvider.Credential; configurationServer.EnsureAuthenticated(); var catalogNode = configurationServer.CatalogNode; var tpcNodes = catalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); var result = this.Engine.Array.Construct(); foreach (var teamProjectCollection in tpcNodes .Select(p => configurationServer.GetTeamProjectCollection(new Guid(p.Resource.Properties["InstanceId"]))) .Where(teamProjectCollection => teamProjectCollection != null)) { ArrayInstance.Push(result, new TfsTeamProjectCollectionInstance(this.Engine.Object.InstancePrototype, teamProjectCollection)); } return(result); }
/// <summary> /// connect to a TFS Server. /// </summary> /// <param name="tfsUri">Possible URI of the TFS Server</param> /// <returns>The correct Tfs Uri</returns> public Uri ConnectToTfsServer(Uri tfsUri) { bool tfsIsConnected = false; //The URI we get from FoundationServerExt_ProjectContextChanged does not allow us to connect to the server //Trim the URI from back to front till connection can be established while (!tfsIsConnected && tfsUri.AbsolutePath != tfsUri.Authority) { m_TfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); tfsUri = new Uri( tfsUri.OriginalString.Substring(0, tfsUri.OriginalString.LastIndexOf('/'))); // workaround: if tfsConfigurationServer.EnsureAuthenticated() fails it doesn't set tfsIsConnected to true and continues to trim uri try { m_TfsConfigurationServer.EnsureAuthenticated(); tfsIsConnected = true; } catch (TeamFoundationServerException) { tfsIsConnected = false; } } if (tfsIsConnected) { FetchProjects(); } return(tfsUri); }
private static void ListProjects() { // URI of the team project collection string _myUri = @"https://bupa-international.visualstudio.com"; TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(_myUri)); CatalogNode catalogNode = configurationServer.CatalogNode; ReadOnlyCollection <CatalogNode> tpcNodes = catalogNode.QueryChildren( new Guid[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // tpc = Team Project Collection foreach (CatalogNode tpcNode in tpcNodes) { Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection tpc = configurationServer.GetTeamProjectCollection(tpcId); // Get catalog of tp = 'Team Projects' for the tpc = 'Team Project Collection' var tpNodes = tpcNode.QueryChildren( new Guid[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); foreach (var p in tpNodes) { Debug.Write(Environment.NewLine + " Team Project : " + p.Resource.DisplayName + " - " + p.Resource.Description + Environment.NewLine); } } }
static void Main() { var tfsUri = new Uri("http://xx.xx.xx.xx:8080/tfs"); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // List the team project collections foreach (CatalogNode collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); // Print the name of the team project collection Console.WriteLine("Collection: " + teamProjectCollection.Name); // Get a catalog of team projects for the collection ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren( new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); // List the team projects in the collection foreach (CatalogNode projectNode in projectNodes) { Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName); } } }
public void createConfigurationServer(Uri uri) { TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri); _configurationServer = configurationServer; }
public static TfsConfigurationServer Get_ConfigurationServer( string tfsUri) { Int64 startTicks = Log.DOMAINSERVICES("Enter", Common.LOG_APPNAME); Uri uri = new Uri(tfsUri); TfsConfigurationServer configurationServer; try { configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri); } catch (TimeoutException) { throw; } catch { throw; } Log.DOMAINSERVICES("Exit", Common.LOG_APPNAME, startTicks); return(configurationServer); }
public static TfsConfigurationServer AuthenticateToTFSService() { Uri tfsUri = new Uri(GetConfigValue("$Instance.VSOnlineUri$")); string username = GetConfigValue("$Instance.Username$"); string password = GetConfigValue("$Instance.Password$"); NetworkCredential netCred = new NetworkCredential(username, password); BasicAuthCredential basicCred = new BasicAuthCredential(netCred); TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred); tfsCred.AllowInteractive = false; TfsConfigurationServer configurationServer = new TfsConfigurationServer(new Uri(tfsUrl), tfsCred); configurationServer.Authenticate(); return(configurationServer); //If you specify a provider, the user will be provided with a prompt to provide non-default credentials ICredentialsProvider provider = new UICredentialsProvider(); TfsConfigurationServer tfs = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri, provider); try { //Prompts the user for credentials if they have not already been authenticated tfs.EnsureAuthenticated(); } catch (TeamFoundationServerUnauthorizedException) { //Handle the TeamFoundationServerUnauthorizedException that is thrown when the user clicks 'Cancel' //in the authentication prompt or if they are otherwise unable to be successfully authenticated tfs = null; } return(tfs); }
public static TfsConfigurationServer GetConfigurationServerAndAuthenticate(Uri tfsUrl) { TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUrl); tfsConfigurationServer.Authenticate(); return(tfsConfigurationServer); }
public TfsTeamProjectCollection GetTfsTeamProjectCollection(Guid collectionId, Uri tfsServer) { TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsServer); var collection = configurationServer.GetTeamProjectCollection(collectionId); return(collection); }
public static TfsConfigurationServer GetConfigurationServerAndAuthenticate(Uri tfsUrl, string domain, string userName, string password) { TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUrl); tfsConfigurationServer.Credentials = new NetworkCredential(userName, password, domain); tfsConfigurationServer.Authenticate(); return(tfsConfigurationServer); }
public static void GetAllCollections(string tfsCollectionUri) { Uri configurationServerUri = new Uri(tfsCollectionUri); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(configurationServerUri); ITeamProjectCollectionService tpcService = configurationServer.GetService <ITeamProjectCollectionService>(); var tpc = tpcService.GetCollections(); }
public static string GetLastSuccededDropLocation(string projName, string buildDefinitionName) { projName = GetProjectName(projName); var cred = new NetworkCredential("SERVICE_ACCOUNT_NAME", "SERVICE_ACCOUNT_PASSWORD", "SERVICE_ACCOUNT_DOMAIN"); var configurationServerUri = new Uri("TFS_URL_TILL_COLLECTION"); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(configurationServerUri); CatalogNode configurationServerNode = configurationServer.CatalogNode; // Query the children of the configuration server node for all of the team project collection nodes ReadOnlyCollection <CatalogNode> tpcNodes = configurationServerNode.QueryChildren( new Guid[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); foreach (CatalogNode tpcNode in tpcNodes) { ServiceDefinition tpcServiceDefinition = tpcNode.Resource.ServiceReferences["Location"]; ILocationService configLocationService = configurationServer.GetService <ILocationService>(); Uri tpcUri = new Uri(configLocationService.LocationForCurrentConnection(tpcServiceDefinition)); // Actually connect to the team project collection TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcUri); ITestManagementService tms = tpc.GetService <ITestManagementService>(); ITestManagementTeamProject proj = tms.GetTeamProject(projName); IBuildServer tfsBuildServer = tpc.GetService <IBuildServer>(); // Reading from XML try { IBuildServer buildServer = (IBuildServer)tpc.GetService(typeof(IBuildServer)); //Specify query IBuildDetailSpec spec = buildServer.CreateBuildDetailSpec(projName.Trim(), buildDefinitionName.Trim()); spec.InformationTypes = null; // for speed improvement spec.QueryOrder = BuildQueryOrder.FinishTimeAscending; //get the latest build only spec.QueryOptions = QueryOptions.All; IBuildDetail bDetail = buildServer.QueryBuilds(spec).Builds.OrderBy(x => x.CompilationStatus == BuildPhaseStatus.Succeeded).Last(); LatestTestBuild = bDetail.DropLocation; LoggerUtil.LogMessageToFile("The ip resolve"); IPAddress ip = null; string arr2 = LatestTestBuild.Split('\\')[2]; Network.GetResolvedConnecionIPAddress(LatestTestBuild.Split('\\')[2], out ip); string temp = string.Join(@"\", LatestTestBuild.Split('\\').Select(s => s.Replace(arr2, ip.ToString())).ToArray()); LatestTestBuild = temp; LoggerUtil.LogMessageToFile(LatestTestBuild); break; } catch { } } return(LatestTestBuild); }
public List <TeamProjectCollection> GetTeamProjectCollections(Uri tfsServer) { TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsServer); var tpcService = configurationServer.GetService <ITeamProjectCollectionService>(); var tfsTeamCollection = tpcService.GetCollections().ToList(); return(tfsTeamCollection); }
protected void GetServices(out Workspace workspace, out VersionControlServer versionControlServer) { var workstation = Workstation.Current; Log.LogMessage(MessageImportance.Normal, "workstation name: " + workstation.Name); var workspaceInfo = workstation.GetLocalWorkspaceInfo(LocalPath); var serverCollectionUrl = workspaceInfo.ServerUri; Log.LogMessage(MessageImportance.Normal, "serverCollectionUrl: " + serverCollectionUrl); var uri = new Uri(GetVDirUrl(serverCollectionUrl)); Log.LogMessage(MessageImportance.Normal, "serverUrl: " + uri); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); workspace = null; versionControlServer = null; // List the team project collections foreach (CatalogNode collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); if (collectionId == workspaceInfo.ServerGuid) { TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); versionControlServer = teamProjectCollection.GetService <VersionControlServer>(); workspace = workspaceInfo.GetWorkspace(teamProjectCollection); Log.LogMessage(MessageImportance.Normal, "found workspace for collectionId: " + collectionId); break; } } if (workspace == null) { Log.LogError("No workspace found."); } if (versionControlServer == null) { Log.LogError("No VersionControlServer found."); } }
private static TfsConfigurationServer Connect(string tfsServerUrl) { // Set the URI of the Team Foundation Server Uri tfsServerUri = new Uri(tfsServerUrl); // Get a TfsConfigurationServer instance TfsConfigurationServer configServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsServerUri); configServer.EnsureAuthenticated(); return(configServer); }
protected override void ProcessRecord() { var uri = new Uri(ServerUri); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri); var tpcService = configurationServer.GetService <ITeamProjectCollectionService>(); WriteObject(tpcService.GetCollections(), true); base.ProcessRecord(); }
public TfsApi() { Server = new Uri("http://vstfdevdiv:8080"); var configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(Server); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); TfsTeamProjectCollection tpc = null; // List the team project collections foreach (CatalogNode collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); if (teamProjectCollection.Name.ToLower().EndsWith("devdiv2")) { tpc = teamProjectCollection; break; } } if (tpc == null) { return; } _workItemStore = tpc.GetService <WorkItemStore>(); Projects = new BindingList <TfsProject>(); foreach (Project project in _workItemStore.Projects) { var tfsProject = new TfsProject(project); if (project.Name.Equals("DevDiv")) { Projects.Insert(0, tfsProject); } else { Projects.Add(tfsProject); } } _selectedProject = Projects[0]; _queryItems = TfsQueryItem.CreateTreeView(_selectedProject); _state = null; }
static void Main(string[] args) { string rootLogFolder = ConfigurationManager.AppSettings["RootLogFolder"].ToString(); try { Console.WriteLine("*** Scanning all Team Projects in all Team Project Collections ***"); string tfsRootUrl = ConfigurationManager.AppSettings["TfsRootUrl"].ToString(); Console.WriteLine("Tfs Root Url: " + tfsRootUrl); Uri tfsConfigurationServerUri = new Uri(tfsRootUrl); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsConfigurationServerUri); ITeamProjectCollectionService tpcService = configurationServer.GetService <ITeamProjectCollectionService>(); string configDbConnectionString = ConfigurationManager.AppSettings["ConfigDBConnectionString"].ToString(); Console.WriteLine("Config DB Connectionstring: " + configDbConnectionString); using (IVssDeploymentServiceHost deploymentServiceHost = CreateDeploymentServiceHost(configDbConnectionString)) { foreach (TeamProjectCollection tpc in tpcService.GetCollections().OrderBy(tpc => tpc.Name)) { string nameOfLogFile = "UpgradeTeamProjectFeatures-" + tpc.Name + ".txt"; string fullPathOfLogFile = System.IO.Path.Combine(rootLogFolder, nameOfLogFile); System.IO.StreamWriter logFile = new System.IO.StreamWriter(fullPathOfLogFile); logFile.WriteLine(String.Format("*** scanning Team Projects in TPC {0} ***", tpc.Name)); logFile.WriteLine(); string tpcUrl = tfsRootUrl + "/" + tpc.Name; TfsTeamProjectCollection tfsCollection = new TfsTeamProjectCollection(new Uri(tpcUrl)); WorkItemStore witStore = tfsCollection.GetService <WorkItemStore>(); foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.Project project in witStore.Projects) { Console.WriteLine("Team Project " + project.Name); logFile.WriteLine(">> Team Project " + project.Name); RunFeatureEnablement(deploymentServiceHost, project, tfsCollection.InstanceId, logFile); logFile.WriteLine(); } logFile.Close(); } } } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary> /// main function /// </summary> /// <param name="args"></param> private static void Main(string[] args) { //string path1 = "ISH3\\ISH3_KBL\\KBL_RS2\\Test"; string logPath = Directory.GetCurrentDirectory(); string logfile = Path.Combine(logPath, "log-file.txt"); if (File.Exists(logfile)) { File.Delete(logfile); } ILog log = LogManager.GetLogger("testApp.Logging"); try { Uri tfsUri = new Uri(ConfigurationManager.AppSettings["TfsUri"]); //Uri tfsUri = new Uri("https://tfs-alm.intel.com:8088/tfs/"); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); var collectionNode = collectionNodes.Single(); // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId); //Console.WriteLine("Collection: " + teamProjectCollection.Name); log.InfoFormat("Collecton: {0}", teamProjectCollection.Name); //log.Info("---------------------------------"); log.Info("*********************************"); workItemStore = teamProjectCollection.GetService <WorkItemStore>(); //ICommonStructureService css = teamProjectCollection.GetService<ICommonStructureService>(); //"ISH3\ISH3_KBL\KBL_RS2\Test" log.Info("path:" + args[0]); string path = args[0]; string[] folder = path.Split('\\'); for (int i = 0; i < folder.Length; i++) { log.Info("folder[" + i + "]:" + folder[i]); } if (!CreateCycle(folder)) { return; } log.Info("Create test cycle:" + args[0] + " successfully!"); } catch (Exception e) { log.Info(e.Message.ToString()); return; } }
static partial void RealInstanceFactory(ref CatalogNode real, string callerName) { // IServiceProvider serviceProvider = new DummyServiceProvider(); // string content = ""; // using (XmlReader reader = XmlReader.Create(new StringReader(content))) // { // real = CatalogNode.FromXml(serviceProvider, reader); // } //CredentialsStore credentials = CredentialsProvider.Read(@"..\..\..\RestCredentials.xml"); //var uri = new Uri(credentials.VsoCollection); var uri = new Uri("http://localhost:8080/tfs"); TfsConfigurationServer tf = TfsConfigurationServerFactory.GetConfigurationServer(uri); real = tf.CatalogNode; }
public Tfs(Uri tfsUri) { TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // List the team project collections foreach (CatalogNode collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection tfs = configurationServer.GetTeamProjectCollection(collectionId); store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); } }
public void IntegrationTestUpdateRetentionPolicies() { TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri("myTfsUrl")); tfsConfigurationServer.Authenticate(); TeamProjectDtoCollection allTeamProjectCollections = tfsConfigurationServer.GetAllTeamProjectsInAllTeamProjectCollections(); foreach (TeamProjectDto teamProjectDto in allTeamProjectCollections) { TfsTeamProjectCollection teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectDto.CollectionId); IBuildServer buildServer = teamProjectCollection.GetService <IBuildServer>(); BuildServerFacade buildServerFacade = new BuildServerFacade(buildServer); buildServerFacade.UpdateRetentionPolicies(teamProjectDto.DisplayName, 1, 5, 5, 10, "All"); } }
public ConnectionState ConnectToServer(Uri serverUri, out List <TeamProjectCollectionData> teamProjectCollections) { IsConnected = false; teamProjectCollections = new List <TeamProjectCollectionData>(); try { _configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(serverUri); // Get the catalog of team project collections ReadOnlyCollection <CatalogNode> collectionNodes = _configurationServer.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); // List the team project collections foreach (CatalogNode collectionNode in collectionNodes) { // Use the InstanceId property to get the team project collection Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection teamProjectCollection = _configurationServer.GetTeamProjectCollection(collectionId); // Get a catalog of team projects for the collection ReadOnlyCollection <CatalogNode> projectNodes = collectionNode.QueryChildren( new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); // List the team projects in the collection string[] teamProjectNames = projectNodes.Select(it => it.Resource.DisplayName).ToArray(); teamProjectCollections.Add(new TeamProjectCollectionData() { Name = teamProjectCollection.Name, Uri = teamProjectCollection.Uri, TeamProjectNames = teamProjectNames }); } } catch (UnauthorizedAccessException) { return(ConnectionState.AuthorizationError); } catch (Exception ex) { //throw new MyTFSConnectionException(" exception on connect:\n" + ex.ToString()); Popups.ShowMessage("Exception on connect: " + ex.ToString(), MessageBoxImage.Error); return(ConnectionState.UnknownError); } IsConnected = true; return(ConnectionState.Connected); }
public IList <Collection> GetCollections() { Uri tfsUri = new Uri(this.Url); TfsConfigurationServer configuracao = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri); ITeamProjectCollectionService tpcService = configuracao.GetService <ITeamProjectCollectionService>(); IList <TeamProjectCollection> tfsCollections = tpcService.GetCollections(); IList <Collection> collections = new List <Collection>(); foreach (TeamProjectCollection tpc in tfsCollections) { collections.Add(new Collection(tpc.Name)); } return(collections); }