public void DeployEnvironmentAsync(Guid uniqueClientId, string requesterIdentity, string targetEnvironment, List <ProjectToDeploy> projects) { Guard.NotEmpty(uniqueClientId, "uniqueClientId"); Guard.NotNullNorEmpty(requesterIdentity, "requesterIdentity"); Guard.NotNullNorEmpty(targetEnvironment, "targetEnvironment"); EnvironmentDeployInfo environmentDeployInfo = _environmentDeployInfoRepository.FindByName(targetEnvironment); if (environmentDeployInfo == null) { throw new FaultException <EnvironmentDeployConfigurationNotFoundFault>(new EnvironmentDeployConfigurationNotFoundFault { EnvironmentName = targetEnvironment }); } List <ProjectDeploymentData> projectsToDeploy = CreateProjectEnvironmentDeployments(uniqueClientId, environmentDeployInfo, projects).ToList(); ThreadPool.QueueUserWorkItem( state => { EventHandler <DiagnosticMessageEventArgs> deploymentPipelineDiagnosticMessageAction = (eventSender, tmpArgs) => LogMessage(uniqueClientId, tmpArgs.MessageType, tmpArgs.Message); try { _envDeploymentPipeline.DiagnosticMessagePosted += deploymentPipelineDiagnosticMessageAction; _envDeploymentPipeline.StartDeployment(targetEnvironment, projectsToDeploy, new DeploymentContext(requesterIdentity)); } finally { _envDeploymentPipeline.DiagnosticMessagePosted -= deploymentPipelineDiagnosticMessageAction; } }); }
public List <string> GetProjectsForEnvironmentDeploy(string environmentName) { EnvironmentDeployInfo environmentDeployInfo = _environmentDeployInfoRepository.FindByName(environmentName); if (environmentDeployInfo == null) { return(null); } return(environmentDeployInfo.ProjectsToDeploy); }
private IEnumerable <ProjectDeploymentData> CreateProjectEnvironmentDeployments(Guid uniqueClientId, EnvironmentDeployInfo environmentDeployInfo, IEnumerable <ProjectToDeploy> projects) { var projectDeployments = new List <ProjectDeploymentData>(); var priorityProjectDeplyoments = new List <ProjectDeploymentData>(); EnvironmentInfo environmentInfo = _environmentInfoRepository.FindByName(environmentDeployInfo.TargetEnvironment); if (environmentInfo == null) { throw new FaultException <EnvironmentNotFoundFault>(new EnvironmentNotFoundFault { EnvironmentName = environmentDeployInfo.TargetEnvironment }); } foreach (var projectToDeploy in projects) { try { ProjectInfo projectInfo = _projectInfoRepository.FindByName(projectToDeploy.ProjectName); if (projectInfo == null) { throw new DeploymentTaskException(string.Format("Not found configuration for project: {0}", projectToDeploy.ProjectName)); } ProjectConfigurationBuild lastSuccessfulBuild = GetLatestSuccessfulBuild(projectToDeploy.ProjectName, environmentDeployInfo.BuildConfigurationName); if (lastSuccessfulBuild == null) { throw new DeploymentTaskException(string.Format("Successful build not found for project: {0} and configuration: {1}", projectToDeploy, environmentDeployInfo.BuildConfigurationName)); } InputParams inputParams = BuildInputParams(projectInfo, environmentInfo); var deploymentInfo = new Core.Domain.DeploymentInfo(projectToDeploy.DeploymentId, false, projectToDeploy.ProjectName, environmentDeployInfo.BuildConfigurationName, lastSuccessfulBuild.Id, environmentDeployInfo.TargetEnvironment, inputParams); DeploymentTask deploymentTask; // TODO LK: could replace below code with factory if (projectInfo.Type == ProjectType.Db) { DeploymentTask dropDbProjectDeploymentTask = new DropDbProjectDeploymentTask( ObjectFactory.Instance.CreateProjectInfoRepository(), ObjectFactory.Instance.CreateEnvironmentInfoRepository(), ObjectFactory.Instance.CreateDbManagerFactory()); priorityProjectDeplyoments.Add(new ProjectDeploymentData(deploymentInfo, projectInfo, dropDbProjectDeploymentTask)); deploymentTask = new DeployDbProjectDeploymentTask( ObjectFactory.Instance.CreateProjectInfoRepository(), ObjectFactory.Instance.CreateEnvironmentInfoRepository(), ObjectFactory.Instance.CreateArtifactsRepository(), ObjectFactory.Instance.CreateDbScriptRunnerFactory(), ObjectFactory.Instance.CreateDbVersionProvider(), ObjectFactory.Instance.CreateFileAdapter(), ObjectFactory.Instance.CreateZipFileAdapter(), ObjectFactory.Instance.CreateScriptsToRunWebSelectorForEnvironmentDeploy(), ObjectFactory.Instance.CreateMsSqlDatabasePublisher(), ObjectFactory.Instance.CreateDbManagerFactory(), ObjectFactory.Instance.CreateUserNameNormalizer(), ObjectFactory.Instance.CreateDirectoryAdapter()); } else if (projectInfo.Type == ProjectType.NtService) { deploymentTask = new DeployNtServiceDeploymentTask( ObjectFactory.Instance.CreateProjectInfoRepository(), ObjectFactory.Instance.CreateEnvironmentInfoRepository(), ObjectFactory.Instance.CreateArtifactsRepository(), ObjectFactory.Instance.CreateNtServiceManager(), ObjectFactory.Instance.CreatePasswordCollector(), ObjectFactory.Instance.CreateFailoverClusterManager(), ObjectFactory.Instance.CreateDirectoryAdapter(), ObjectFactory.Instance.CreateFileAdapter(), ObjectFactory.Instance.CreateZipFileAdapter()) { UseLocalSystemUser = true }; } else { deploymentTask = projectInfo.CreateDeploymentTask(ObjectFactory.Instance); } projectDeployments.Add(new ProjectDeploymentData(deploymentInfo, projectInfo, deploymentTask)); } catch (Exception e) { LogMessage(uniqueClientId, DiagnosticMessageType.Error, e.Message); } } priorityProjectDeplyoments.AddRange(projectDeployments); return(priorityProjectDeplyoments); }