Example #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);
        }
Example #2
0
        public PipelineEnvironment(DeliveryPipeline pipeline, string environmentName, IBuildDefinition buildDefinition)
        {
            Pipeline        = pipeline;
            EnvironmentName = environmentName;
            BuildDefinition = buildDefinition;

            IsCommitBuildVisibility = EnvironmentName.Equals("Commit", StringComparison.InvariantCultureIgnoreCase) ? Visibility.Visible : Visibility.Collapsed;

            LastStatus          = new PipelineEnvironmentBuildStatus(null);
            LastBuildFinishTime = DateTime.MaxValue;
            LastBuildNumber     = "0";

            _queuedBuildsView = BuildDefinition.BuildServer.CreateQueuedBuildsView(new Uri[] { BuildDefinition.Uri });

            _queuedBuildsView.StatusFilter = QueueStatus.InProgress | QueueStatus.Queued;
            _queuedBuildsView.QueryOptions = QueryOptions.Definitions;

            _buildSpec = Pipeline.Source.BuildServer.CreateBuildDetailSpec(BuildDefinition);
            _buildSpec.InformationTypes = null;

            StartPolling();
        }