|
|
@@ -1,11 +1,11 @@
|
|
|
package cn.seecoder.web.service.impl.pipeline;
|
|
|
|
|
|
import cn.seecoder.web.dao.pipeline.DeploymentMapper;
|
|
|
-import cn.seecoder.web.dao.pipeline.PipelineHistoryMapper;
|
|
|
+import cn.seecoder.web.dao.pipeline.PipelineRecordMapper;
|
|
|
import cn.seecoder.web.dao.pipeline.PipelineMapper;
|
|
|
import cn.seecoder.web.dao.project.ProjectMapper;
|
|
|
import cn.seecoder.web.model.po.pipeline.DeploymentPO;
|
|
|
-import cn.seecoder.web.model.po.pipeline.PipelineHistoryPO;
|
|
|
+import cn.seecoder.web.model.po.pipeline.PipelineRecordPO;
|
|
|
import cn.seecoder.web.model.po.pipeline.PipelinePO;
|
|
|
import cn.seecoder.web.model.po.project.ProjectPO;
|
|
|
import io.kubernetes.client.openapi.models.V1DeploymentStatus;
|
|
|
@@ -39,7 +39,7 @@ public class DeploymentServiceImpl implements DeploymentService {
|
|
|
|
|
|
private final PipelineMapper pipelineMapper;
|
|
|
|
|
|
- private final PipelineHistoryMapper pipelineHistoryMapper;
|
|
|
+ private final PipelineRecordMapper pipelineRecordMapper;
|
|
|
|
|
|
private final ProjectMapper projectMapper;
|
|
|
|
|
|
@@ -49,9 +49,9 @@ public class DeploymentServiceImpl implements DeploymentService {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- public DeploymentServiceImpl(PipelineMapper pipelineMapper, PipelineHistoryMapper pipelineHistoryMapper, ProjectMapper projectMapper, ApplicationProperties properties, DeploymentMapper deploymentMapper) {
|
|
|
+ public DeploymentServiceImpl(PipelineMapper pipelineMapper, PipelineRecordMapper pipelineRecordMapper, ProjectMapper projectMapper, ApplicationProperties properties, DeploymentMapper deploymentMapper) {
|
|
|
this.pipelineMapper = pipelineMapper;
|
|
|
- this.pipelineHistoryMapper = pipelineHistoryMapper;
|
|
|
+ this.pipelineRecordMapper = pipelineRecordMapper;
|
|
|
this.projectMapper = projectMapper;
|
|
|
this.properties = properties;
|
|
|
this.deploymentMapper = deploymentMapper;
|
|
|
@@ -97,14 +97,14 @@ public class DeploymentServiceImpl implements DeploymentService {
|
|
|
PipelinePO pipelinePO = pipelineMapper.selectById(pipelineId);
|
|
|
ProjectPO projectPO = projectMapper.getProjectById(projectId);
|
|
|
//历史记录
|
|
|
- PipelineHistoryPO history = PipelineHistoryPO.builder()
|
|
|
+ PipelineRecordPO record = PipelineRecordPO.builder()
|
|
|
.result("部署中")
|
|
|
.pipelineId(pipelinePO.getId())
|
|
|
.userId(userId)
|
|
|
.details("")
|
|
|
.startTime(new Timestamp(System.currentTimeMillis()))
|
|
|
.build();
|
|
|
- pipelineHistoryMapper.insert(history);
|
|
|
+ pipelineRecordMapper.insert(record);
|
|
|
|
|
|
|
|
|
DeploymentPO deployment = deploymentMapper.selectByPipelineId(pipelineId);
|
|
|
@@ -116,31 +116,31 @@ public class DeploymentServiceImpl implements DeploymentService {
|
|
|
.deployName(pipelinePO.getName())
|
|
|
.accessUrl(accessUrl)
|
|
|
.pipelineId(pipelineId)
|
|
|
- .deployedTime(history.getStartTime())
|
|
|
+ .deployedTime(record.getStartTime())
|
|
|
.build());
|
|
|
} else {
|
|
|
- deployment.setDeployedTime(history.getStartTime());
|
|
|
+ deployment.setDeployedTime(record.getStartTime());
|
|
|
deploymentMapper.update(deployment);
|
|
|
}
|
|
|
|
|
|
Pipeline pipeline = null;
|
|
|
try {
|
|
|
pipeline = PipelineFactory.init(pipelinePO.getConfigJson(), projectPO.getUniqueK8sNamespace(), pipelinePO.getName());
|
|
|
- pipeline.addConfig("pipelineHistoryId", history.getId().toString());
|
|
|
+ pipeline.addConfig("pipelineRecordId", record.getId().toString());
|
|
|
pipeline.start();
|
|
|
- history.setResult("部署成功");
|
|
|
- history.setDetails(pipeline.getContext().getResult());
|
|
|
+ record.setResult("部署成功");
|
|
|
+ record.setDetails(pipeline.getContext().getResult());
|
|
|
} catch (PipelineException e) {
|
|
|
- history.setResult("部署失败");
|
|
|
- history.setDetails(pipeline.getContext().getResult());
|
|
|
+ record.setResult("部署失败");
|
|
|
+ record.setDetails(pipeline.getContext().getResult());
|
|
|
throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR,"应用部署失败",e);
|
|
|
} catch (RuntimeException e){
|
|
|
pipeline.getContext().appendErrorResult("运行时错误: ", e);
|
|
|
- history.setResult("部署失败");
|
|
|
- history.setDetails(pipeline.getContext().getResult());
|
|
|
+ record.setResult("部署失败");
|
|
|
+ record.setDetails(pipeline.getContext().getResult());
|
|
|
throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR,"应用部署失败",e);
|
|
|
} finally {
|
|
|
- pipelineHistoryMapper.update(history);
|
|
|
+ pipelineRecordMapper.update(record);
|
|
|
}
|
|
|
|
|
|
}
|