public DeployAllResult DeployAll(ServerConfiguration server, string configurationName, string branchName, bool switchToBranch, bool updateSubmodules) { _logInfo("Deployment all projects to " + server + " from " + configurationName + " branch " + branchName); var result = new DeployAllResult(); var index = -1; foreach (var deployProject in CurrentDeployConfiguration.ProjectConfigurations) { index++; var gitProjectInfo = _userOptions.GetProjectInfo(deployProject.WorkingDirectory); if (gitProjectInfo == null) { result.AppendLine(deployProject.Name + ": project does not exists in main list"); continue; } var configuration = deployProject.GetConfiguration(configurationName); if (configuration == null) { result.AppendLine(deployProject.Name + ": configuration " + configurationName + " does not exists"); continue; } var gitProject = CurrentGitProjectList.GetOrAddProject(gitProjectInfo, _userOptions); if (!gitProject.BranchExists(branchName)) { result.AppendLine(deployProject.Name + ": branch " + branchName + " does not exists"); continue; } var iisAppInfo = server.IisAppList.FirstOrDefault(r => r.LinkedProjectName == deployProject.Name); if (iisAppInfo == null) { result.AppendLine(deployProject.Name + ": Iis App for this project is not configured"); continue; } var deployUserSelection = new DeployUserSelection { DeployProject = deployProject, Server = server, BuildConfiguration = configuration, IisApp = server.IisAppList[index].IisAppName, BranchName = branchName, SwitchToBranch = switchToBranch, UpdateSubmodules = updateSubmodules }; if (!Deploy(deployUserSelection)) { result.AppendLine(deployProject.Name + ": deploy is not successful! Please see logs!"); continue; } } return result; }
public bool Deploy(DeployUserSelection deployUserSelection) { _logInfo(deployUserSelection.DeployProject.Name + "..."); var gitProjectInfo = _userOptions.GetProjectInfo(deployUserSelection.DeployProject.WorkingDirectory); if (gitProjectInfo != null) { var gitProject = CurrentGitProjectList.GetOrAddProject(gitProjectInfo, _userOptions); if (gitProject == null) return false; if (deployUserSelection.SwitchToBranch) { _logInfo(deployUserSelection.DeployProject.Name + ": switching to " + deployUserSelection.BranchName + "..."); gitProject.SmartSwitch(deployUserSelection.BranchName, deployUserSelection.UpdateSubmodules); } } var deployArguments = deployUserSelection.GetDeployArguments(); var deployer = new Deployer(deployArguments); _logInfo("Deploying " + deployArguments.WorkingDirectory + " to server " + deployArguments.ServerName + "..."); _logInfo(deployUserSelection.DeployProject.Name + " deployment..."); deployer.Deploy(); return deployer.DeployResult; }