private void ComponentDeploymentSuccess(ComponentVertexDeploymentProgress value) { var name = GetName(value); var flowId = GetFlowId(value); var timeStamp = GetJavaTimeStamp(); var progressMessage = _serviceMessageFormatter.FormatMessage("progressMessage", _logMessages.DeploymentSuccess(value.Vertex)); var testIgnoredMessage = _serviceMessageFormatter.FormatMessage("testIgnored", new { name = name, message = _logMessages.DeploymentSkipped(value.Vertex), flowId = flowId, timeStamp = timeStamp }); var testFinishMessage = _serviceMessageFormatter.FormatMessage("testFinished", new { name = name, flowId = flowId, timeStamp = timeStamp }); if (value.Vertex.DeploymentAction != PlanAction.Change) { Console.Out.WriteLine(testIgnoredMessage); } Console.Out.WriteLine(progressMessage); Console.Out.WriteLine(testFinishMessage); }
public void Report(ComponentVertexDeploymentProgress value) { if (value != null) { switch (value.Status) { case ComponentVertexDeploymentStatus.NotStarted: ComponentDeploymentNotStarted(value); break; case ComponentVertexDeploymentStatus.Started: ComponentDeploymentStarted(value); break; case ComponentVertexDeploymentStatus.InProgress: ComponentDeploymentInProgress(value); break; case ComponentVertexDeploymentStatus.Failure: ComponentDeploymentFailure(value); break; case ComponentVertexDeploymentStatus.Cancelled: ComponentDeploymentCancelled(value); break; case ComponentVertexDeploymentStatus.Success: ComponentDeploymentSuccess(value); break; default: throw new ArgumentOutOfRangeException(); } } }
private void ComponentDeploymentFailure(ComponentVertexDeploymentProgress value) { var name = GetName(value); var flowId = GetFlowId(value); var timeStamp = GetJavaTimeStamp(); var progressMessage = _serviceMessageFormatter.FormatMessage("progressMessage", _logMessages.DeploymentFailed(value.Vertex, value.Text)); var buildProblemMessage = _serviceMessageFormatter.FormatMessage("buildProblem", new { description = _logMessages.DeploymentFailed(value.Vertex, value.Text), identity = name, flowId = flowId, timeStamp = timeStamp }); var testFailedMessage = _serviceMessageFormatter.FormatMessage("testFailed", new { name = name, message = _logMessages.DeploymentFailed(value.Vertex, value.Text), details = _logMessages.DeploymentFailed(value.Vertex, value.Text), flowId = flowId, timeStamp = timeStamp }); var failedDeploymentMessage = _serviceMessageFormatter.FormatMessage("message", new { text = _logMessages.DeploymentFailed(value.Vertex, value.Text), errorDetails = _logMessages.DeploymentFailed(value.Vertex, value.Text), status = "ERROR", flowId = flowId, timeStamp = timeStamp }); var testFinishMessage = _serviceMessageFormatter.FormatMessage("testFinished", new { name = name, flowId = flowId, timeStamp = timeStamp }); Console.Out.WriteLine(progressMessage); Console.Out.WriteLine(buildProblemMessage); Console.Out.WriteLine(testFailedMessage); Console.Out.WriteLine(failedDeploymentMessage); Console.Out.WriteLine(testFinishMessage); }
private void ComponentDeploymentStarted(ComponentVertexDeploymentProgress value) { var name = GetName(value); var flowId = GetFlowId(value); var timeStamp = GetJavaTimeStamp(); var progressMessage = _serviceMessageFormatter.FormatMessage("progressMessage", _logMessages.DeploymentStarted(value.Vertex)); var testStartedMessage = _serviceMessageFormatter.FormatMessage("testStarted", new { name = name, flowId = flowId, timeStamp = timeStamp }); Console.Out.WriteLine(progressMessage); Console.Out.WriteLine(testStartedMessage); }
private void ComponentDeploymentCancelled(ComponentVertexDeploymentProgress value) { var name = GetName(value); var flowId = GetFlowId(value); var timeStamp = GetJavaTimeStamp(); var progressMessage = _serviceMessageFormatter.FormatMessage("progressMessage", _logMessages.DeploymentCancelled(value.Vertex)); var testFailedMessage = _serviceMessageFormatter.FormatMessage("testFailed", new { name = name, message = _logMessages.DeploymentCancelled(value.Vertex), details = _logMessages.DeploymentCancelled(value.Vertex), flowId = flowId, timeStamp = timeStamp }); var cancelledDeploymentMessage = _serviceMessageFormatter.FormatMessage("message", new { text = _logMessages.DeploymentCancelled(value.Vertex), errorDetails = _logMessages.DeploymentCancelled(value.Vertex), status = "ERROR", flowId = flowId, timeStamp = timeStamp }); var testFinishMessage = _serviceMessageFormatter.FormatMessage("testFinished", new { name = name, flowId = flowId, timeStamp = timeStamp }); Console.Out.WriteLine(progressMessage); Console.Out.WriteLine(testFailedMessage); Console.Out.WriteLine(cancelledDeploymentMessage); Console.Out.WriteLine(testFinishMessage); }
private void ComponentDeploymentCancelled(ComponentVertexDeploymentProgress value) { Console.Out.WriteLine(_logMessages.DeploymentCancelled(value.Vertex)); }
private void ComponentDeploymentFailure(ComponentVertexDeploymentProgress value) { Console.Out.WriteLine(_logMessages.DeploymentFailed(value.Vertex, value.Text)); }
private void ComponentDeploymentInProgress(ComponentVertexDeploymentProgress value) { }
private void ComponentDeploymentNotStarted(ComponentVertexDeploymentProgress value) { }
public ComponentVertexDeploymentResult Deploy(ComponentDeploymentVertex componentDeploymentVertex, CancellationToken cancellationToken, ILogMessages logMessages, IProgress <ComponentVertexDeploymentProgress> progress) { if (!componentDeploymentVertex.Exists || componentDeploymentVertex.DeploymentAction == PlanAction.Skip) { return(new ComponentVertexDeploymentResult { Status = ComponentVertexDeploymentStatus.Success, Description = logMessages.DeploymentSkipped(componentDeploymentVertex) }); } if (componentDeploymentVertex.Version == null) { throw new Exception("Version for release is null"); } var environment = _repository.Environments.GetEnvironment(_environmentToDeployTo.Name); var project = _repository.Projects.GetProjectByName(componentDeploymentVertex.Name); var release = _repository.Projects.GetRelease(project.Id, componentDeploymentVertex.Version); var deployment = new DeploymentResource { ReleaseId = release.Id, EnvironmentId = environment.Id, Comments = _comments, ForcePackageDownload = _forcePackageDownload, ForcePackageRedeployment = _forcePackageRedeployment, }; var queuedDeployment = _repository.Deployments.Create(deployment); componentDeploymentVertex.DeploymentId = queuedDeployment.Id; var deploymentTask = _repository.Tasks.Get(queuedDeployment.TaskId); Action <TaskResource[]> interval = tasks => { foreach (var task in tasks) { if (cancellationToken.IsCancellationRequested) { _repository.Tasks.Cancel(task); } var duration = new TimeSpan(0); if (task.StartTime.HasValue) { var now = new DateTimeOffset(DateTime.UtcNow); duration = now.Subtract(task.StartTime.Value); } if (progress != null) { var componentVertexDeploymentProgress = new ComponentVertexDeploymentProgress { Vertex = componentDeploymentVertex, Status = ComponentVertexDeploymentStatus.InProgress, MinimumValue = 0, MaximumValue = componentDeploymentVertex.DeploymentDuration.HasValue ? componentDeploymentVertex.DeploymentDuration.Value.Ticks : 0, Value = duration.Ticks, Text = logMessages.DeploymentProgress(componentDeploymentVertex, task.Description) }; progress.Report(componentVertexDeploymentProgress); } } }; _repository.Tasks.WaitForCompletion(deploymentTask, _pollIntervalSeconds, _timeoutAfterMinutes, interval); deploymentTask = _repository.Tasks.Get(queuedDeployment.TaskId); var result = new ComponentVertexDeploymentResult(); switch (deploymentTask.State) { case TaskState.Success: result.Status = ComponentVertexDeploymentStatus.Success; result.Description = logMessages.DeploymentSuccess(componentDeploymentVertex); break; case TaskState.Canceled: case TaskState.Cancelling: result.Status = ComponentVertexDeploymentStatus.Cancelled; result.Description = logMessages.DeploymentCancelled(componentDeploymentVertex); break; case TaskState.Failed: case TaskState.TimedOut: result.Status = ComponentVertexDeploymentStatus.Failure; result.Description = logMessages.DeploymentFailed(componentDeploymentVertex, deploymentTask.ErrorMessage); break; default: result.Status = ComponentVertexDeploymentStatus.Failure; result.Description = logMessages.DeploymentFailed(componentDeploymentVertex, deploymentTask.ErrorMessage); break; } return(result); }
private string GetName(ComponentVertexDeploymentProgress value) { return(string.IsNullOrEmpty(value.Vertex.Name) ? value.Vertex.Id : value.Vertex.Name); }