|
|
@@ -10,7 +10,6 @@ import cn.reghao.autodop.dmaster.app.constant.BuildStage;
|
|
|
import cn.reghao.autodop.dmaster.app.constant.CompilerType;
|
|
|
import cn.reghao.autodop.common.deploy.PackerType;
|
|
|
import cn.reghao.autodop.dmaster.app.constant.RepoType;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.deploy.AppDeploy;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.log.BuildDeployLog;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.BuildLog;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.DeployLog;
|
|
|
@@ -58,17 +57,8 @@ public class AppIntegrate {
|
|
|
private PreCompile preCompile;
|
|
|
private CodeCompiler codeCompiler;
|
|
|
private CodePacker codePacker;
|
|
|
-
|
|
|
private AppDeployer appDeployer;
|
|
|
|
|
|
- /*public AppIntegrate() {
|
|
|
- }
|
|
|
-
|
|
|
- public void setApp(AppOrchestration app) {
|
|
|
- this.app = app;
|
|
|
- init();
|
|
|
- }*/
|
|
|
-
|
|
|
public AppIntegrate(AppOrchestration app, AppDeployer appDeployer) {
|
|
|
this.app = app;
|
|
|
this.appDeployer = appDeployer;
|
|
|
@@ -80,7 +70,7 @@ public class AppIntegrate {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 若 AppOrchestration 发生变化则重新初始化
|
|
|
+ * TODO 若 AppOrchestration 发生变化则重新初始化
|
|
|
*
|
|
|
* @param
|
|
|
* @return
|
|
|
@@ -158,14 +148,6 @@ public class AppIntegrate {
|
|
|
} else if (appPack.getPackerType().equals(PackerType.zip.name())) {
|
|
|
codePacker = new ZipPack(appPackDir);
|
|
|
}
|
|
|
-
|
|
|
- // TODO 特定于 dnkt-mgr 项目的处理
|
|
|
- /*if (app.getAppId().startsWith("dnkt-mgr")) {
|
|
|
- codePacker = new DntkMgrDockerPack(appPack.getPackerPath(), app.getEnv());
|
|
|
- }*/
|
|
|
-
|
|
|
- // TODO 初始化部署配置
|
|
|
- AppDeploy appDeploy = app.getAppDeploy();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -193,15 +175,13 @@ public class AppIntegrate {
|
|
|
}
|
|
|
|
|
|
if (lastCommitLog == null) {
|
|
|
- lastCommitLog = codeUpdater.lastCommitInfo(local, branch);
|
|
|
+ lastCommitLog = codeUpdater.lastCommitInfo(local + "/" + app.getDirname(), branch);
|
|
|
}
|
|
|
|
|
|
- AppUpdateStatus updateStatus = update0(remote, branch, local);
|
|
|
- lastCommitLog = updateStatus.getLastCommitLog();
|
|
|
- lastCommitLog.setRemoteRepoUrl(app.getAppRepo());
|
|
|
- buildLog.setCommitLog(lastCommitLog);
|
|
|
-
|
|
|
- if (updateStatus.isUpdated()) {
|
|
|
+ UpdateStatus updateStatus = update0(remote, branch, local);
|
|
|
+ if (updateStatus.isUpdated) {
|
|
|
+ lastCommitLog = updateStatus.getLastCommitLog();
|
|
|
+ buildLog.setCommitLog(lastCommitLog);
|
|
|
BuilderUtil.copyToCompileDir(local, app);
|
|
|
return true;
|
|
|
} else {
|
|
|
@@ -221,28 +201,27 @@ public class AppIntegrate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private AppUpdateStatus update0(String remote, String branch, String local) throws Exception {
|
|
|
+ private UpdateStatus update0(String remote, String branch, String local) throws Exception {
|
|
|
CommitLog current = codeUpdater.update(remote, branch, local);
|
|
|
- if (lastCommitLog == null
|
|
|
- || current.getCommitTime() > lastCommitLog.getCommitTime()
|
|
|
- || app.isAlwaysBuild()) {
|
|
|
+ if (lastCommitLog != null) {
|
|
|
+ if (lastCommitLog.getCommitId().equals(current.getCommitId())) {
|
|
|
+ return new UpdateStatus(current, false);
|
|
|
+ } else if (lastCommitLog.getCommitTime() > current.getCommitTime()) {
|
|
|
+ throw new Exception("本地仓库代码比远程仓库更新...");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (app.getProj() == null) {
|
|
|
- // TODO 拉取应用依赖的其他仓库(若存在)
|
|
|
- Set<String> deps = app.getDependencyRepos();
|
|
|
- if (deps != null && !deps.isEmpty()) {
|
|
|
- for (String repo : deps) {
|
|
|
- if (!repo.isEmpty()) {
|
|
|
- codeUpdater.update(repo, app.getBranch(), appLocalRepo + app.getDirname());
|
|
|
- }
|
|
|
- }
|
|
|
+ // TODO 拉取应用依赖的其他仓库(若存在)
|
|
|
+ Set<String> deps = app.getDependencyRepos();
|
|
|
+ if (app.getProj() == null && deps != null) {
|
|
|
+ for (String repo : deps) {
|
|
|
+ if (!repo.isEmpty()) {
|
|
|
+ codeUpdater.update(repo, app.getBranch(), appLocalRepo + app.getDirname());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return new AppUpdateStatus(app, current, true);
|
|
|
- } else {
|
|
|
- return new AppUpdateStatus(app, current, false);
|
|
|
}
|
|
|
+
|
|
|
+ return new UpdateStatus(current, true);
|
|
|
}
|
|
|
|
|
|
public boolean compile() {
|
|
|
@@ -297,8 +276,7 @@ public class AppIntegrate {
|
|
|
|
|
|
@Data
|
|
|
@AllArgsConstructor
|
|
|
- static class AppUpdateStatus {
|
|
|
- private AppOrchestration app;
|
|
|
+ static class UpdateStatus {
|
|
|
private CommitLog lastCommitLog;
|
|
|
private boolean isUpdated;
|
|
|
}
|