|
@@ -2,43 +2,43 @@ package cn.reghao.autodop.dmaster.app.service.build;
|
|
|
|
|
|
|
|
import cn.reghao.autodop.common.config.BuildDeployResult;
|
|
import cn.reghao.autodop.common.config.BuildDeployResult;
|
|
|
import cn.reghao.autodop.common.utils.JsonUtil;
|
|
import cn.reghao.autodop.common.utils.JsonUtil;
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.pojo.orchestration.AppOrchestration;
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.service.deploy.AppDeploy;
|
|
|
import cn.reghao.autodop.dmaster.orchestrate.pojo.SysConfig;
|
|
import cn.reghao.autodop.dmaster.orchestrate.pojo.SysConfig;
|
|
|
-import cn.reghao.autodop.dmaster.orchestrate.pojo.orchestration.AppOrchestration;
|
|
|
|
|
-import cn.reghao.autodop.dmaster.app.service.build.tools.vc.VersionControl;
|
|
|
|
|
|
|
+import cn.reghao.autodop.dmaster.app.service.tools.updater.CodeUpdater;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Callable;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 应用构建任务
|
|
|
|
|
|
|
+ * 应用更新 -> 编译 -> 打包 -> 部署流水线
|
|
|
|
|
+ * 每个应用都对应一个构建任务
|
|
|
*
|
|
*
|
|
|
* @author reghao
|
|
* @author reghao
|
|
|
* @date 2019-11-16 21:39:53
|
|
* @date 2019-11-16 21:39:53
|
|
|
*/
|
|
*/
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
-public class AppBuildPipeline implements Callable<String> {
|
|
|
|
|
|
|
+public class AppPipeline implements Callable<String> {
|
|
|
private AppOrchestration app;
|
|
private AppOrchestration app;
|
|
|
private String version;
|
|
private String version;
|
|
|
private boolean isDeploy;
|
|
private boolean isDeploy;
|
|
|
- private boolean isRun;
|
|
|
|
|
private AppIntegrate appIntegrate;
|
|
private AppIntegrate appIntegrate;
|
|
|
|
|
|
|
|
private final String appLocalRepo;
|
|
private final String appLocalRepo;
|
|
|
private final String appCompileDir;
|
|
private final String appCompileDir;
|
|
|
|
|
|
|
|
- public AppBuildPipeline(AppOrchestration app, String version, boolean isDeploy, boolean isRun) {
|
|
|
|
|
|
|
+ public AppPipeline(AppOrchestration app, String version, boolean isDeploy) {
|
|
|
this.app = app;
|
|
this.app = app;
|
|
|
this.version = version;
|
|
this.version = version;
|
|
|
this.isDeploy = isDeploy;
|
|
this.isDeploy = isDeploy;
|
|
|
- this.isRun = isRun;
|
|
|
|
|
this.appIntegrate = new AppIntegrate(app);
|
|
this.appIntegrate = new AppIntegrate(app);
|
|
|
// TODO 暂时不使用动态代理
|
|
// TODO 暂时不使用动态代理
|
|
|
/*this.appIntegrate = ProxyUtils.createProxyObject(AppIntegrate.class);
|
|
/*this.appIntegrate = ProxyUtils.createProxyObject(AppIntegrate.class);
|
|
|
this.appIntegrate.setApp(app);*/
|
|
this.appIntegrate.setApp(app);*/
|
|
|
|
|
|
|
|
- this.appLocalRepo = SysConfig.localRepos + "/" + app.getIdentifier();
|
|
|
|
|
- this.appCompileDir = SysConfig.compileDir + "/" + app.getIdentifier();
|
|
|
|
|
|
|
+ this.appLocalRepo = SysConfig.localRepos + "/" + app.getAppId();
|
|
|
|
|
+ this.appCompileDir = SysConfig.compileDir + "/" + app.getAppId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -51,8 +51,19 @@ public class AppBuildPipeline implements Callable<String> {
|
|
|
@Override
|
|
@Override
|
|
|
public String call() {
|
|
public String call() {
|
|
|
BuildDeployResult result = new BuildDeployResult();
|
|
BuildDeployResult result = new BuildDeployResult();
|
|
|
- result.setAppId(app.getIdentifier());
|
|
|
|
|
- /* 更新阶段 */
|
|
|
|
|
|
|
+ result.setAppId(app.getAppId());
|
|
|
|
|
+
|
|
|
|
|
+ if (version == null ) {
|
|
|
|
|
+ appIntegrate.update();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ appIntegrate.compile();
|
|
|
|
|
+ appIntegrate.pack();
|
|
|
|
|
+ if (isDeploy) {
|
|
|
|
|
+ appIntegrate.deploy();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 更新阶段 *//*
|
|
|
if (version == null ) {
|
|
if (version == null ) {
|
|
|
try {
|
|
try {
|
|
|
version = updateApp();
|
|
version = updateApp();
|
|
@@ -65,7 +76,7 @@ public class AppBuildPipeline implements Callable<String> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
result.setVersion(version);
|
|
result.setVersion(version);
|
|
|
- log.info("{} -> 代码更新完成", app.getIdentifier());
|
|
|
|
|
|
|
+ log.info("{} -> 代码更新完成", app.getAppId());
|
|
|
|
|
|
|
|
String appEntryDir;
|
|
String appEntryDir;
|
|
|
if (app.getProjBuild() != null) {
|
|
if (app.getProjBuild() != null) {
|
|
@@ -75,12 +86,12 @@ public class AppBuildPipeline implements Callable<String> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- /* 编译阶段 */
|
|
|
|
|
|
|
+ *//* 编译阶段 *//*
|
|
|
if (appIntegrate.needPreCompile()) {
|
|
if (appIntegrate.needPreCompile()) {
|
|
|
- appIntegrate.preCompile(appEntryDir);
|
|
|
|
|
|
|
+ //appIntegrate.preCompile(appEntryDir);
|
|
|
}
|
|
}
|
|
|
// TODO 在通过脚本调用编译器时会卡住
|
|
// TODO 在通过脚本调用编译器时会卡住
|
|
|
- appIntegrate.compile(appEntryDir);
|
|
|
|
|
|
|
+ //appIntegrate.compile(app.getDirname(), appEntryDir);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
result.setStage("编译");
|
|
result.setStage("编译");
|
|
@@ -89,9 +100,9 @@ public class AppBuildPipeline implements Callable<String> {
|
|
|
}
|
|
}
|
|
|
log.info("{} -> 编译完成", app.getIdentifier());
|
|
log.info("{} -> 编译完成", app.getIdentifier());
|
|
|
|
|
|
|
|
- /* 打包阶段 */
|
|
|
|
|
|
|
+ *//* 打包阶段 *//*
|
|
|
try {
|
|
try {
|
|
|
- appIntegrate.pack(app.getIdentifier(), String.valueOf(version), appEntryDir);
|
|
|
|
|
|
|
+ //appIntegrate.pack(app.getIdentifier(), String.valueOf(version), appEntryDir);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
result.setStage("打包");
|
|
result.setStage("打包");
|
|
@@ -100,25 +111,25 @@ public class AppBuildPipeline implements Callable<String> {
|
|
|
}
|
|
}
|
|
|
log.info("{} -> 打包完成", app.getIdentifier());
|
|
log.info("{} -> 打包完成", app.getIdentifier());
|
|
|
|
|
|
|
|
- /* 部署阶段 */
|
|
|
|
|
|
|
+ *//* 部署阶段 *//*
|
|
|
if (isDeploy) {
|
|
if (isDeploy) {
|
|
|
List<BuildDeployResult> results = null;
|
|
List<BuildDeployResult> results = null;
|
|
|
try {
|
|
try {
|
|
|
- results = AppDeploy.deploy(app, version, isRun);
|
|
|
|
|
|
|
+ results = AppDeploy.deploy(app, version);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
log.info("{} -> 部署完成", app.getIdentifier());
|
|
log.info("{} -> 部署完成", app.getIdentifier());
|
|
|
return JsonUtil.objectToJson(results);
|
|
return JsonUtil.objectToJson(results);
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
|
|
return JsonUtil.objectToJson(result);
|
|
return JsonUtil.objectToJson(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String updateApp() throws Exception {
|
|
|
|
|
|
|
+ /*private String updateApp() throws Exception {
|
|
|
String remoteRepo = app.getBuild().getCodeRepos().getReposUrl();
|
|
String remoteRepo = app.getBuild().getCodeRepos().getReposUrl();
|
|
|
- VersionControl vc = BuilderUtil.versionControl(app.getBuild().getCodeRepos().getReposAuth());
|
|
|
|
|
|
|
+ CodeUpdater vc = BuilderUtil.versionControl(app.getBuild().getCodeRepos().getReposAuth());
|
|
|
String version = vc.update(remoteRepo, appLocalRepo + BuilderUtil.dirname(remoteRepo));
|
|
String version = vc.update(remoteRepo, appLocalRepo + BuilderUtil.dirname(remoteRepo));
|
|
|
|
|
|
|
|
String dep = app.getBuild().getCodeRepos().getDependencyUrls();
|
|
String dep = app.getBuild().getCodeRepos().getDependencyUrls();
|
|
@@ -129,5 +140,5 @@ public class AppBuildPipeline implements Callable<String> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return version;
|
|
return version;
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
}
|
|
}
|