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 void ComponentDeploymentSuccess(ComponentVertexDeploymentProgress value) { Console.Out.WriteLine(_logMessages.DeploymentSuccess(value.Vertex)); }
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); }