Beispiel #1
0
        public IList <DeliveryPipeline> GetPipelines()
        {
            IList <DeliveryPipeline> pipelines = new List <DeliveryPipeline>();

            Uri collectionUri = new Uri(Uri);

            ProjectCollection = new TfsTeamProjectCollection(collectionUri);

            BuildServer            = ProjectCollection.GetService <IBuildServer>();
            CommonStructureService = ProjectCollection.GetService <ICommonStructureService>();
            Registration           = ProjectCollection.GetService <IRegistration>();
            VersionControlServer   = ProjectCollection.GetService <VersionControlServer>();
            ClientHyperlinkService = ProjectCollection.GetService <TswaClientHyperlinkService>();

            Name = ProjectCollection.CatalogNode.Resource.DisplayName;

            if (BuildServer.BuildServerVersion.ToString() == "v3")
            {
                TfsVersion = 2010;
            }
            else
            {
                TfsVersion = 2012;
            }

            foreach (ProjectInfo project in CommonStructureService.ListProjects())
            {
                foreach (IBuildDefinition definition in BuildServer.QueryBuildDefinitions(project.Name))
                {
                    if (definition.Process.ServerPath.Contains("BuildProcessTemplates/PowerDelivery"))
                    {
                        IDictionary <string, object> processParams = WorkflowHelpers.DeserializeProcessParameters(definition.ProcessParameters);

                        if (processParams.ContainsKey("PowerShellScriptPath"))
                        {
                            string scriptPath = processParams["PowerShellScriptPath"] as string;

                            string scriptName = System.IO.Path.GetFileNameWithoutExtension(scriptPath.Substring(scriptPath.LastIndexOf("/")));

                            string environmentName = definition.Name.Substring(definition.Name.LastIndexOf(" - ") + 3);

                            DeliveryPipeline pipeline = pipelines.FirstOrDefault(p => p.ScriptName == scriptName);

                            if (pipeline == null)
                            {
                                pipeline = new DeliveryPipeline(this, project, scriptName);
                                pipelines.Add(pipeline);
                            }

                            PipelineEnvironment environment = new PipelineEnvironment(pipeline, environmentName, definition);

                            pipeline.Environments.Add(environment);
                        }
                    }
                }
            }

            return(pipelines);
        }
 public NodeInfo GetNodeInfo(string nodeUri)
 {
     try
     {
         return(CommonStructureService.GetNode(nodeUri));
     }
     catch (Exception e)
     {
         throw new AuthenticationException("The user svcTfsTestSenter does not have permission to access the specified area. Error Message: " + e);
     }
 }