/// <summary> /// 创建任务计划 /// </summary> /// <param name="projectAction"></param> private void CreateSchTasks(DepProjectAction projectAction) { DepProjectItem projectItem = SvnProcesser.ProjectItem(projectAction.DepId); string targetPath = string.Empty; targetPath = projectItem.DeployPath.Replace("/", @"\"); if (targetPath.IndexOf(":") == -1) { targetPath = CommandExeHelper.CombineDir(DEPLOY_ROOT, targetPath); } targetPath = CommandExeHelper.CombineDir(targetPath, projectItem.ExcludeFile); string strOutput = SchTasksOperate.Create(projectItem.WebSite, targetPath); Logger.SaveLog(strOutput); SvnProcesser.UpdateDeployStatus(projectAction.Id, SUCCESS, strOutput); }
/// <summary> /// 部署Python脚本 /// </summary> /// <param name="projectAction"></param> private bool DeployPython(DepProjectAction projectAction) { string msg = ""; bool result = true; string pythonPath = ConfigHelper.GetSetting("DEPLOY_Python_Path", "PyScript"); DepProjectItem projectItem = SvnProcesser.ProjectItem(projectAction.DepId); DepProject project = SvnProcesser.Project(projectItem.DepId); //目标路径 string targetPath = projectItem.DeployPath.Replace("/", @"\"); if (targetPath.IndexOf(":") == -1) { targetPath = CommandExeHelper.CombineDir(DEPLOY_ROOT, targetPath); //Python目录 targetPath = CommandExeHelper.CombineDir(targetPath, pythonPath); } if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } string checkSharePath = CommandExeHelper.CombineDir(SVN_UPDATE_ROOT, project.Id.ToString()); checkSharePath = CommandExeHelper.CombineDir(checkSharePath, project.SharePath); //Python目录 checkSharePath = CommandExeHelper.CombineDir(checkSharePath, pythonPath); string exclude = "";//string.IsNullOrEmpty(project.ExcludeFile) ? "" : string.Format("/xf {0}", project.ExcludeFile); //更新共享的目录,如Code目录 string robarguments = string.Format("{0} {1} /MIR {2}", checkSharePath, targetPath, exclude); Logger.SaveLog(string.Format("SvnDeploy Python shared directory robocopy.exe {0}", robarguments)); msg += CommandExeHelper.Run("robocopy.exe", robarguments); SvnProcesser.UpdateDeployStatus(projectAction.Id, SUCCESS, msg); return(result); }
private bool DoDeploy(DepProjectAction projectAction, ref string msg) { bool result = true; DepProjectItem projectItem = SvnProcesser.ProjectItem(projectAction.DepId); DepProject project = SvnProcesser.Project(projectItem.DepId); string checkSharePath = CommandExeHelper.CombineDir(SVN_UPDATE_ROOT, project.Id.ToString()); string targetPath = string.Empty; targetPath = projectItem.DeployPath.Replace("/", @"\"); if (targetPath.IndexOf(":") == -1) { targetPath = CommandExeHelper.CombineDir(DEPLOY_ROOT, targetPath); } if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } if (!string.IsNullOrEmpty(project.SharePath.Trim())) { checkSharePath = CommandExeHelper.CombineDir(checkSharePath, project.SharePath); string exclude = "";//string.IsNullOrEmpty(project.ExcludeFile) ? "" : string.Format("/xf {0}", project.ExcludeFile); //更新共享的目录,如Code目录 string robarguments = string.Format("{0} {1} /MIR {2}", checkSharePath, targetPath, exclude); Logger.SaveLog(string.Format("SvnDeploy shared directory robocopy.exe {0}", robarguments)); msg += CommandExeHelper.Run("robocopy.exe", robarguments); } //差异目录,如天界行1服目录下的Web.Config文件 string checkOutPath = CommandExeHelper.CombineDir(SVN_UPDATE_ROOT, project.Id.ToString()); checkOutPath = CommandExeHelper.CombineDir(checkOutPath, projectItem.Name); bool isExist = Directory.Exists(checkOutPath); if (isExist) { //合并Debug与Release目录文件 string arguments = string.Empty; if (IsRelease) { arguments = string.Format("{0} {1} /e/y", checkOutPath, targetPath); } else { arguments = string.Format("{0} {1} /e/y", Path.Combine(checkOutPath, "Debug"), targetPath); } Logger.SaveLog(string.Format("SvnDeploy differences in directory xcopy.exe {0}", arguments)); msg += CommandExeHelper.Run("xcopy.exe", arguments); } //支持以前目录结构 else if (string.IsNullOrEmpty(project.SharePath.Trim())) { checkOutPath = CommandExeHelper.CombineDir(SVN_UPDATE_ROOT, project.Id.ToString()); string arguments = string.Format("{0} {1} /e/y", checkOutPath, targetPath); Logger.SaveLog(string.Format("SvnDeploy old directory xcopy.exe {0}", arguments)); msg += CommandExeHelper.Run("xcopy.exe", arguments); } else { result = false; msg += string.Format("Directory error:{0} {1}", checkOutPath, targetPath); } return(result); }