|
|
@@ -1,6 +1,7 @@
|
|
|
package cn.reghao.autodop.dmaster.app.service.build;
|
|
|
|
|
|
import cn.reghao.autodop.common.config.BuildDeployResult;
|
|
|
+import cn.reghao.autodop.common.http.HttpApi;
|
|
|
import cn.reghao.autodop.common.utils.JsonUtil;
|
|
|
import cn.reghao.autodop.dmaster.app.pojo.BuildMsg;
|
|
|
import cn.reghao.autodop.dmaster.app.service.build.tools.notifier.DingNotify;
|
|
|
@@ -36,10 +37,22 @@ public class AppDeploy {
|
|
|
AppPacker appPacker = app.getBuild().getAppPacker();
|
|
|
String packerType = appPacker.getPackerType();
|
|
|
String appPath = "";
|
|
|
+ // 根据不同的打包类型,确定应用的地址
|
|
|
if ("docker".equalsIgnoreCase(packerType)) {
|
|
|
appPath = appPacker.getAppRootPath() + "/" + app.getIdentifier() + ":" + version;
|
|
|
} else if ("zip".equalsIgnoreCase(packerType)) {
|
|
|
- appPath = app.getIdentifier() + "_" + version;
|
|
|
+ String env = app.getEnv();
|
|
|
+ // 根据应用环境确定 autodop 的地址和端口
|
|
|
+ if ("test".equals(env)) {
|
|
|
+ appPath = HttpApi.url("192.168.0.50", 4000,
|
|
|
+ "/api/app/file/dl/" + app.getIdentifier() + "_" + version + ".zip");
|
|
|
+ } else if ("prod".equals(env)) {
|
|
|
+ appPath = HttpApi.url("static.iquizoo.com", 80,
|
|
|
+ "/api/app/file/dl/" + app.getIdentifier() + "_" + version + ".zip");
|
|
|
+ } else {
|
|
|
+ appPath = HttpApi.url("localhost", 4000,
|
|
|
+ "/api/app/file/dl/" + app.getIdentifier() + "_" + version + ".zip");
|
|
|
+ }
|
|
|
} else if ("zip-remote".equalsIgnoreCase(packerType)) {
|
|
|
// TODO zip-remote 使用 zip 打包,并将应用包上传到远程服务器,appRootPath 是一个 HTTP 链接
|
|
|
appPath = appPacker.getAppRootPath() + app.getIdentifier() + "_" + version;
|
|
|
@@ -47,8 +60,10 @@ public class AppDeploy {
|
|
|
|
|
|
List<BuildDeployResult> results = Deployer.deploy(app, appPath, isRun);
|
|
|
for (BuildDeployResult result : results) {
|
|
|
- if ("成功".equalsIgnoreCase(result.getMsg())) {
|
|
|
- log.info("{} 部署成功", app.getIdentifier());
|
|
|
+ result.setVersion(version);
|
|
|
+ result.setDescription(app.getDescription());
|
|
|
+ if ("运行".equals(result.getStage()) && result.getCode() == 0) {
|
|
|
+ log.info("{} 已运行", app.getIdentifier());
|
|
|
BuildMsg buildMsg =
|
|
|
new BuildMsg(app.getIdentifier(), app.getDescription(), version, app.getEnv());
|
|
|
// TODO 异步通知
|