Beispiel #1
0
        public async Task ConfigureNotifications(
            string projectName,
            string projectPath,
            bool persistChanges = true,
            PipelineSelectionStrategy strategy = PipelineSelectionStrategy.Scheduled)
        {
            var pipelines = await GetPipelinesAsync(projectName, projectPath, strategy);

            var teams = await service.GetTeamsAsync(projectName);

            foreach (var pipeline in pipelines)
            {
                using (logger.BeginScope("Evaluate Pipeline Name = {0}, Path = {1}, Id = {2}", pipeline.Name, pipeline.Path, pipeline.Id))
                {
                    var parentTeam = await EnsureTeamExists(pipeline, "Notifications", TeamPurpose.ParentNotificationTeam, teams, persistChanges);

                    var childTeam = await EnsureTeamExists(pipeline, "Sync Notifications", TeamPurpose.SynchronizedNotificationTeam, teams, persistChanges);

                    if (!persistChanges && (parentTeam == default || childTeam == default))
                    {
                        // Skip team nesting and notification work if
                        logger.LogInformation("Skipping Teams and Notifications because parent or child team does not exist");
                        continue;
                    }

                    await EnsureSynchronizedNotificationTeamIsChild(parentTeam, childTeam, persistChanges);
                    await EnsureScheduledBuildFailSubscriptionExists(pipeline, parentTeam, persistChanges);

                    // Associate
                }
            }
        }
Beispiel #2
0
        private async Task <IEnumerable <WebApiTeam> > GetAllTeamsAsync(string projectName)
        {
            var accumulator = new List <WebApiTeam>();
            var skip        = 0;
            IEnumerable <WebApiTeam> teams;

            while (true)
            {
                teams = await service.GetTeamsAsync(projectName, skip : skip);

                if (!teams.Any())
                {
                    break;
                }

                accumulator.AddRange(teams);
                skip = accumulator.Count;
            }

            return(accumulator);
        }