|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.reghao.autodop.dmaster.app.vo.log;
|
|
|
|
|
|
+import cn.reghao.autodop.common.utils.DatetimeConverter;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.BuildLog;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.DeployLog;
|
|
|
import lombok.Data;
|
|
|
@@ -16,74 +17,43 @@ import java.util.List;
|
|
|
@Data
|
|
|
@NoArgsConstructor
|
|
|
public class BuildDeployResult {
|
|
|
- private String appId;
|
|
|
- private String commitId;
|
|
|
- private String commitMsg;
|
|
|
- private String buildTime;
|
|
|
- private boolean isDeploy;
|
|
|
// 0 - 成功 1 - 失败
|
|
|
private int statusCode;
|
|
|
private String msg;
|
|
|
+
|
|
|
+ private String appId;
|
|
|
+ private String commitId;
|
|
|
+ private String bdType;
|
|
|
+ private String bdTime;
|
|
|
private List<String> deploySuccessed;
|
|
|
private List<String> deployFailure;
|
|
|
|
|
|
- public BuildDeployResult(String appId) {
|
|
|
- this.appId = appId;
|
|
|
- this.isDeploy = false;
|
|
|
- }
|
|
|
-
|
|
|
public static BuildDeployResult fromBuildLog(BuildLog buildLog) {
|
|
|
BuildDeployResult buildDeployResult = new BuildDeployResult();
|
|
|
- /*buildDeployResult.setAppId(buildLog.getAppId());
|
|
|
- buildDeployResult.setBuildTime(DatetimeConverter.format(buildLog.getBuildTime()));
|
|
|
- buildDeployResult.setDeploy(false);
|
|
|
+ buildDeployResult.setAppId(buildLog.getAppId());
|
|
|
+ buildDeployResult.setCommitId(buildLog.getCommitId());
|
|
|
+ buildDeployResult.setBdType("构建");
|
|
|
+ buildDeployResult.setBdTime(DatetimeConverter.format(buildLog.getBuildTime()));
|
|
|
buildDeployResult.setStatusCode(buildLog.getStatusCode());
|
|
|
- buildDeployResult.setMsg(buildLog.getMsg());
|
|
|
if (buildLog.getStatusCode() == 0) {
|
|
|
- buildDeployResult.setCommitId(buildLog.getCommitLog().getCommitId());
|
|
|
- buildDeployResult.setCommitMsg(buildLog.getCommitLog().getCommitMsg());
|
|
|
- return buildDeployResult;
|
|
|
+ buildDeployResult.setMsg("构建成功");
|
|
|
} else {
|
|
|
- if (buildLog.getCommitLog() != null) {
|
|
|
- buildDeployResult.setCommitId(buildLog.getCommitLog().getCommitId());
|
|
|
- buildDeployResult.setCommitMsg(buildLog.getCommitLog().getCommitMsg());
|
|
|
- }
|
|
|
- return buildDeployResult;
|
|
|
- }*/
|
|
|
+ buildDeployResult.setMsg(buildLog.getErrDetail());
|
|
|
+ }
|
|
|
|
|
|
return buildDeployResult;
|
|
|
}
|
|
|
|
|
|
- public static BuildDeployResult fromDeployLogs(List<DeployLog> deployLogs) {
|
|
|
+ public static BuildDeployResult fromDeployLog(DeployLog deployLog) {
|
|
|
BuildDeployResult buildDeployResult = new BuildDeployResult();
|
|
|
- //BuildLog buildLog = deployLogs.get(0).getBuildLog();
|
|
|
- /*buildDeployResult.setAppId(buildLog.getAppId());
|
|
|
- buildDeployResult.setBuildTime(DatetimeConverter.format(buildLog.getBuildTime()));
|
|
|
- buildDeployResult.setDeploy(true);
|
|
|
- buildDeployResult.setCommitId(buildLog.getCommitLog().getCommitId());
|
|
|
- buildDeployResult.setCommitMsg(buildLog.getCommitLog().getCommitMsg());
|
|
|
-
|
|
|
- List<String> successedHosts = deployLogs.stream()
|
|
|
- .filter(deployLog -> deployLog.getStatusCode() == 0)
|
|
|
- .map(DeployLog::getHost)
|
|
|
- .collect(Collectors.toList());
|
|
|
- buildDeployResult.setDeploySuccessed(successedHosts);
|
|
|
+ buildDeployResult.setAppId(deployLog.getAppId());
|
|
|
+ buildDeployResult.setCommitId(deployLog.getCommitId());
|
|
|
+ buildDeployResult.setBdType("部署");
|
|
|
+ buildDeployResult.setBdTime(deployLog.getDeployTime());
|
|
|
|
|
|
- List<String> failedHosts = deployLogs.stream()
|
|
|
- .filter(deployLog -> deployLog.getStatusCode() != 0)
|
|
|
- .map(DeployLog::getHost)
|
|
|
- .collect(Collectors.toList());
|
|
|
- buildDeployResult.setDeployFailure(failedHosts);
|
|
|
+ deployLog.getDeployResults().forEach(deployResult -> {
|
|
|
|
|
|
-
|
|
|
- // 根据部署结果中成功的数量设置返回结果
|
|
|
- if (failedHosts.isEmpty()) {
|
|
|
- buildDeployResult.setStatusCode(0);
|
|
|
- buildDeployResult.setMsg("所有节点部署成功");
|
|
|
- } else {
|
|
|
- buildDeployResult.setStatusCode(1);
|
|
|
- buildDeployResult.setMsg("节点 " + failedHosts.toString() + " 部署失败");
|
|
|
- }*/
|
|
|
+ });
|
|
|
|
|
|
return buildDeployResult;
|
|
|
}
|