public async Task ConfigureNotifications( string projectName, string projectPath, GitHubToAADConverter gitHubToAADConverter, bool persistChanges = true, PipelineSelectionStrategy strategy = PipelineSelectionStrategy.Scheduled) { var pipelines = await GetPipelinesAsync(projectName, projectPath, strategy); var teams = await service.GetAllTeamsAsync(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, TeamPurpose.ParentNotificationTeam, teams, gitHubToAADConverter, persistChanges); var childTeam = await EnsureTeamExists(pipeline, TeamPurpose.SynchronizedNotificationTeam, teams, gitHubToAADConverter, 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); } } }
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.GetAllTeamsAsync(projectName); foreach (var pipeline in pipelines) { // If the pipeline name length is max or greater there is no // room to add differentiators like "-- Sync Notifications" // and this will result in team name collisions. if (pipeline.Name.Length >= MaxTeamNameLength) { throw new Exception($"Pipeline Name outside of character limit: Max = {MaxTeamNameLength}, Actual = {pipeline.Name.Length}, Name = {pipeline.Name}"); } 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 } } }