protected async Task ProvisionEnvironmentPermissionsAsync( Kdoctl.CliServices.AzDoServices.Dtos.Project project, PipelineEnvironmentService peService, EnvironmentManifest pe, PipelineEnvironment envObject) { if (envObject != null && pe.Permissions != null && pe.Permissions.Any()) { foreach (var permissionObject in pe.Permissions) { using var op = Insights.BeginOperation($"Configuring Environment ({pe.Name}) permissions: AAD object ({permissionObject.Group}) ...", "Envrionment"); var group = await GetGroupByNameAsync( permissionObject.Origin, permissionObject.Group, permissionObject.Id); if (group != null) { var legacyIdentity = await GetGraphService() .GetLegacyIdentitiesBySidAsync(group.Sid); if (legacyIdentity != null && legacyIdentity.Value.Any()) { var localId = legacyIdentity.Value.First().Id; foreach (var role in permissionObject.Roles) { await peService.SetPermissionAsync(project.Id, envObject.Id, localId, role); } } } else { op.EndWithFailure("Failed (Not found in AAD)"); } } } }
private void EnvironmentBlockTitle_MouseDown(object sender, MouseButtonEventArgs e) { FrameworkElement blockBorder = (FrameworkElement)sender; PipelineEnvironment environment = (PipelineEnvironment)blockBorder.DataContext; if (environment.LastBuildUri != null) { if (ClientConfiguration.Current.IsInVisualStudio) { _clientControl.OnUrlOpened(new UrlOpenedEventArgs(environment.LastBuildUri.ToString())); } else { Uri viewBuildDetailsUri = environment.Pipeline.Source.ClientHyperlinkService.GetViewBuildDetailsUrl(environment.LastBuildUri); Process.Start(viewBuildDetailsUri.ToString()); } } /* * FrameworkElement blockBorder = (FrameworkElement)sender; * * PipelineEnvironment environment = (PipelineEnvironment)blockBorder.DataContext; * * NavigationService.Navigate(new ShowPipelineEnvironment(environment)); */ }
private void btnEditEnvironmentConfig_Click(object sender, RoutedEventArgs e) { Button btnSource = (Button)sender; PipelineEnvironment environment = (PipelineEnvironment)btnSource.DataContext; try { string localDirectory = environment.Pipeline.GetWorkingDirectory(); if (localDirectory != null) { string envConfigPath = string.Format("{0}\\{1}{2}.yml", localDirectory, environment.Pipeline.ScriptName, environment.EnvironmentName); if (!File.Exists(envConfigPath)) { throw new Exception(string.Format("File:\n\n{0}\n\nCouldn't be found on disk. Did you move your working folder?", envConfigPath)); } ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = envConfigPath; psi.WorkingDirectory = System.IO.Path.GetDirectoryName(envConfigPath); Process.Start(psi); } } catch (Exception ex) { MessageBox.Show(ex.Message, string.Format("Unable to edit {0} environment configuration file", environment.EnvironmentName), MessageBoxButton.OK, MessageBoxImage.Error); } }
private void CommitImage_MouseDown(object sender, MouseButtonEventArgs e) { FrameworkElement commitImage = (FrameworkElement)sender; PipelineEnvironment environment = (PipelineEnvironment)commitImage.DataContext; environment.QueueCommitBuild(); }
public ShowPipelineEnvironment(PipelineEnvironment environment) { Environment = environment; DataContext = environment; InitializeComponent(); txtTitle.Text = string.Format("{0} Releases of {1}", environment.EnvironmentName, environment.Pipeline.ScriptName); }
private static JToken GetEnvironment(JToken existingRelease, PipelineEnvironment env) { var matchingEnv = existingRelease.SelectToken($"$.environments[?(@.id=={env.Id})]"); if (matchingEnv == null) { throw new ArgumentException($"Could not find an environment with id [{env.Id}]"); } return(matchingEnv); }
public PromoteBuildDialog(IList <BuildNumber> buildNumbers, PipelineEnvironment environment, PipelineEnvironment nextEnvironment) { DataContext = this; Environment = environment; NextEnvironment = nextEnvironment; PageTitle = string.Format("Promote {0} to {1}", Environment.Pipeline.ScriptName, NextEnvironment.EnvironmentName); PageDescription = string.Format("Select a successful {0} build to promote to {1}.", Environment.EnvironmentName, NextEnvironment.EnvironmentName); InitializeComponent(); lblPromote.Content = string.Format("{0} Build to Promote: ", Environment.EnvironmentName); SelectedBuildNumber = 0; cboBuilds.ItemsSource = buildNumbers.OrderByDescending(b => b.Number); if (buildNumbers.Count > 0) { cboBuilds.SelectedIndex = 0; } }
private async Task ProvisionEnvironmentPermissionsAsync( Waddle.AdoConnectionFactory factory, Waddle.Dtos.Project project, Waddle.PipelineEnvironmentService peService, EnvironmentManifest pe, PipelineEnvironment envObject) { if (envObject != null && pe.Permissions != null && pe.Permissions.Any()) { foreach (var permissionObject in pe.Permissions) { Logger.StatusBegin($"Configuring Environment ({pe.Name}) permissions: AAD object ({permissionObject.Group}) ..."); var group = await GetGroupByNameAsync(factory, permissionObject.Origin, permissionObject.Group, permissionObject.Id); if (group != null) { var legacyIdentity = await factory.GetGroupService() .GetLegacyIdentitiesBySidAsync(group.Sid); if (legacyIdentity != null && legacyIdentity.Value.Any()) { var localId = legacyIdentity.Value.First().Id; foreach (var role in permissionObject.Roles) { await peService.SetPermissionAsync(project.Id, envObject.Id, localId, role); } Logger.StatusEndSuccess("Succeeded"); } } else { Logger.StatusEndFailed("Failed (Not found in AAD)"); } } } }
private IPipelineEnvironment CreatePipelineEnvironment(IPipelineExecutionInfo pipelineExecutionInfo, PipelineConfiguration configuration) { var result = new PipelineEnvironment(pipelineExecutionInfo); foreach (var handlerRegistration in configuration.CodeFileHandlerTypeRegistrations) { Type type = Type.GetType(handlerRegistration.Type); if (type is null) { throw new InvalidOperationException($"Cannot resolve CodeFileHandler type {handlerRegistration.Type}."); } var codeFileHandlerFactory = Activator.CreateInstance(type) as ICodeFileEnvironmentHandlerFactory; if (codeFileHandlerFactory == null) { throw new InvalidOperationException($"CodeFileHandler type {handlerRegistration.Type} should implement {typeof(ICodeFileEnvironmentHandlerFactory)} interface."); } var handler = codeFileHandlerFactory.Create(this.workspaceManagers.ProcessingWorkspace, this.fileSystem, pipelineExecutionInfo, this.logger, handlerRegistration.Configuration); result.Handlers.Add(handler); } return(result); }
private void brdEnvironmentBlock_Loaded(object sender, RoutedEventArgs e) { Border brdEnvironmentBlock = (Border)sender; Canvas.SetZIndex(brdEnvironmentBlock, 1); FrameworkElement parentElement = (FrameworkElement)brdEnvironmentBlock.TemplatedParent; Canvas parentCanvas = parentElement.Parent as Canvas; PipelineEnvironment environment = brdEnvironmentBlock.DataContext as PipelineEnvironment; IEnumerable <PipelineEnvironment> environments = environment.Pipeline.Environments.Where(env => env.EnvironmentName != "Commit" && env.EnvironmentName != "Test"); int midEnvCount = environments.Count(); if (environment.EnvironmentName == "Production") { Canvas.SetLeft(parentElement, 495); Canvas.SetTop(parentElement, 0); } else if (environment.EnvironmentName == "Commit") { Canvas.SetLeft(parentElement, 0); Canvas.SetTop(parentElement, (midEnvCount * ENV_BLOCK_HEIGHT) / 2 - (ENV_BLOCK_HEIGHT / 2)); } else { Canvas.SetLeft(parentElement, 250); int pipelineIndex = environments.ToList().IndexOf(environment) + 1; PipelineEnvironment commitEnvironment = environment.Pipeline.Environments.FirstOrDefault(env => env.EnvironmentName == "Commit"); PipelineEnvironment productionEnvironment = environment.Pipeline.Environments.FirstOrDefault(env => env.EnvironmentName == "Production"); Canvas.SetTop(parentElement, pipelineIndex == 0 ? 0 : (pipelineIndex - 1) * ENV_BLOCK_HEIGHT); Line commitToMidLine = new Line(); commitToMidLine.StrokeThickness = 3; commitToMidLine.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#555")); commitToMidLine.X1 = 170; commitToMidLine.Y1 = (midEnvCount * ENV_BLOCK_HEIGHT) / 2; commitToMidLine.X2 = Canvas.GetLeft(parentElement); commitToMidLine.Y2 = Canvas.GetTop(parentElement) + (parentElement.ActualHeight / 2); parentCanvas.Children.Add(commitToMidLine); PromoteControl promoteFromCommit = new PromoteControl(this); promoteFromCommit.Environment = commitEnvironment; promoteFromCommit.NextEnvironment = environment; promoteFromCommit.ToolTip = string.Format("Promote {0} from Commit to {1}", environment.Pipeline.ScriptName, environment.EnvironmentName); parentCanvas.Children.Add(promoteFromCommit); RotateTransform rotatePromoteButton = new RotateTransform(); rotatePromoteButton.CenterX = 10; rotatePromoteButton.CenterY = 10; promoteFromCommit.RenderTransform = rotatePromoteButton; Double angleInRadians = Math.Atan2(commitToMidLine.Y2 - commitToMidLine.Y1, commitToMidLine.X2 - commitToMidLine.X1); rotatePromoteButton.Angle = angleInRadians * (180 / Math.PI); if (commitToMidLine.Y2 > commitToMidLine.Y1) { Canvas.SetTop(promoteFromCommit, commitToMidLine.Y1 + ((commitToMidLine.Y2 - commitToMidLine.Y1) / 2) - (promoteFromCommit.ActualHeight / 2) - 16); } else { Canvas.SetTop(promoteFromCommit, commitToMidLine.Y2 + ((commitToMidLine.Y1 - commitToMidLine.Y2) / 2) - (promoteFromCommit.ActualHeight / 2) - 16); } Canvas.SetLeft(promoteFromCommit, 200); if (environment.EnvironmentName == "Test") { Line testToProdLine = new Line(); testToProdLine.StrokeThickness = 3; testToProdLine.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#555")); testToProdLine.X1 = 250 + brdEnvironmentBlock.ActualWidth; testToProdLine.Y1 = Canvas.GetTop(parentElement) + (parentElement.ActualHeight / 2); testToProdLine.X2 = PROD_BLOCK_LEFT; testToProdLine.Y2 = ENV_BLOCK_HEIGHT / 2 - 3; parentCanvas.Children.Add(testToProdLine); PromoteControl promoteFromTest = new PromoteControl(this); promoteFromTest.Environment = environment; promoteFromTest.NextEnvironment = productionEnvironment; promoteFromTest.ToolTip = string.Format("Promote {0} from {1} to Production", environment.Pipeline.ScriptName, environment.EnvironmentName); parentCanvas.Children.Add(promoteFromTest); if (testToProdLine.Y2 > testToProdLine.Y1) { Canvas.SetTop(promoteFromTest, testToProdLine.Y1 + ((testToProdLine.Y2 - testToProdLine.Y1) / 2) - (promoteFromTest.ActualHeight / 2) - 15); } else { Canvas.SetTop(promoteFromTest, testToProdLine.Y2 + ((testToProdLine.Y1 - testToProdLine.Y2) / 2) - (promoteFromTest.ActualHeight / 2) - 15); } Canvas.SetLeft(promoteFromTest, 445); } } }