版本库为空时先从备份版本库检测

This commit is contained in:
wangwei10061 2019-03-27 11:36:55 +08:00
parent ecad6ee293
commit 92c61d2845
4 changed files with 23 additions and 5 deletions

View File

@ -45,6 +45,9 @@ public class AppConfig {
@Value("${gitIP}")
private String gitIP;
@Value("${gitBackUpIP}")
private String gitBackUpIP;
@Value("${outputSize}")
private String outputSize;
@ -105,6 +108,10 @@ public class AppConfig {
return gitIP;
}
public String getGitBackUpIP() {
return gitBackUpIP;
}
public String getDockerMaster() {
return dockerMaster;
}

View File

@ -719,10 +719,19 @@ public class GameService {
JSONObject result = ShellUtil.executeAndGetExitStatus(command);
// 255是连接失败如果连接成功wc -l总是执行的对于前面文件夹为空或者不存在的情况$?总是0输出结果总是0
if ((result.getInteger("exitStatus") == 0 && result.getString("out").equals("0"))) {
logger.error("check方法远程TPI版本库为空,tpiID: {}", tpiID);
response.put("code", -2);
response.put("msg", "finished");
return response;
// 如果版本库为空考虑是迁移到了备份机上
// ssh -p1122 git@10.9.54.50 "mv /home/git/repositories/2018/innov/yvqhfr7a.git/ /home/git/repositories/innov/"
String mvCommand = "mv /home/git/repositories/2018/" + identifier + "/" + tpiRepoName + ".git"
+ " /home/git/repositories/" + identifier + "/";
command = "ssh -p1122 -o StrictHostKeyChecking=no git@" + appConfig.getGitBackUpIP() + " '" + mvCommand + "'";
// 若迁移不成功判定版本库不存在错误
if (ShellUtil.executeAndGetExitStatus(command).getInteger("exitStatus") != 0) {
logger.error("check方法远程TPI版本库为空,tpiID: {}", tpiID);
response.put("code", -2);
response.put("msg", "finished");
return response;
}
}
// 第二个步骤检测远程版本库HEAD是否存在 .git/refs/heads/master没内容就是HEAD丢失了git branch

View File

@ -46,8 +46,9 @@ registry=10.9.105.90:5000
cpuAllocatable=24000
memAllocatable=46160
#IP
#git 版本库IP
gitIP=10.9.62.218
gitBackUpIP=10.9.54.50
#编译结果最大长度
outputSize=65535

View File

@ -42,6 +42,7 @@ registry=10.9.105.90:5000
#IP
gitIP=10.9.73.116
gitBackUpIP=10.9.73.116
#编译结果最大长度
outputSize=65535