service(添加ws依赖)
迁移
This commit is contained in:
parent
2031ce9233
commit
07654e2865
@ -42,6 +42,11 @@
|
||||
<groupId>ognl</groupId>
|
||||
<artifactId>ognl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-websocket</artifactId>
|
||||
<version>6.1.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
@ -1,356 +1,369 @@
|
||||
//package cd.casic.module.process.pipeline.execute.service.impl;
|
||||
//
|
||||
//
|
||||
//import cd.casic.ci.commons.bean.engine.execute.PipelineRunMsg;
|
||||
//import cd.casic.ci.commons.bean.process.instance.PipelineInstance;
|
||||
//import cd.casic.ci.commons.bean.work.agent.model.Agent;
|
||||
//import cd.casic.framework.commons.exception.ServiceException;
|
||||
//import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
//import cd.casic.module.process.engine.task.TasksExecService;
|
||||
//import cd.casic.module.process.pipeline.definition.PipelineService;
|
||||
//import cd.casic.module.process.pipeline.execute.service.PipelineExecService;
|
||||
//import cd.casic.module.process.process.definition.VariableService;
|
||||
//import cd.casic.module.process.process.instance.PipelineInstanceService;
|
||||
//import cd.casic.module.process.setting.service.ResourcesService;
|
||||
//import cd.casic.module.process.setting.service.ScmService;
|
||||
//import cd.casic.module.process.stages.service.StageExecService;
|
||||
//import cd.casic.module.process.stages.service.StageService;
|
||||
//import cd.casic.module.process.support.agent.service.AgentService;
|
||||
//import cd.casic.module.process.support.disk.service.DiskService;
|
||||
//import cd.casic.module.process.support.home.PipelineVersionService;
|
||||
//import cd.casic.module.process.support.postprocess.service.PostprocessExecService;
|
||||
//import cd.casic.module.process.support.util.PipelineUtilService;
|
||||
//import cd.casic.module.process.toolkit.join.JoinTemplate;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
////import org.springframework.web.socket.WebSocketSession;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 流水线运行服务
|
||||
// */
|
||||
//@Service
|
||||
////@Exporter
|
||||
//public class PipelineExecServiceImpl implements PipelineExecService {
|
||||
//
|
||||
// @Autowired
|
||||
// PipelineService pipelineService;
|
||||
//
|
||||
// @Autowired
|
||||
// PostprocessExecService postExecService;
|
||||
//
|
||||
// @Autowired
|
||||
// PipelineInstanceService pipelineInstanceService;
|
||||
//
|
||||
// @Autowired
|
||||
// TasksExecService tasksExecService;
|
||||
//
|
||||
// @Autowired
|
||||
// StageExecService stageExecService;
|
||||
//
|
||||
// @Autowired
|
||||
// ResourcesService resourcesService;
|
||||
//
|
||||
// @Autowired
|
||||
// PipelineVersionService versionService;
|
||||
//
|
||||
// @Autowired
|
||||
// PipelineUtilService utilService;
|
||||
//
|
||||
// @Autowired
|
||||
// DiskService diskService;
|
||||
//
|
||||
// @Autowired
|
||||
// StageService stageService;
|
||||
//
|
||||
// @Autowired
|
||||
// JoinTemplate joinTemplate;
|
||||
//
|
||||
// @Autowired
|
||||
// ScmService scmService;
|
||||
//
|
||||
// @Autowired
|
||||
// VariableService variableService;
|
||||
//
|
||||
// @Autowired
|
||||
// AgentService agentService;
|
||||
//
|
||||
// public final Logger logger = LoggerFactory.getLogger(PipelineExecServiceImpl.class);
|
||||
//
|
||||
// //流水线id:流水线实例id
|
||||
// public static final Map<String,String> pipelineIdOrInstanceId = new HashMap<>();
|
||||
//
|
||||
// //流水线id:agent
|
||||
// public static final Map<String , Agent> pipelineIdOrAgentId = new HashMap<>();
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 流水线开始运行
|
||||
// * @param runMsg 流水线id
|
||||
// * @return 是否正在运行
|
||||
// */
|
||||
// @Override
|
||||
// public PipelineInstance start(PipelineRunMsg runMsg) {
|
||||
// Agent agent;
|
||||
// if (StringUtils.isEmpty(runMsg.getAgentId())){
|
||||
// agent = agentService.findDefaultAgent();
|
||||
// }else {
|
||||
// agent = agentService.findAgent(runMsg.getAgentId());
|
||||
// }
|
||||
// if (Objects.isNull(agent)){
|
||||
// throw new ServiceException(GlobalErrorCodeConstants.LOCKED.getCode(),"无法获取到流水线执行Agent!");
|
||||
// }
|
||||
//
|
||||
// WebSocketSession session = SocketServerHandler.sessionMap.get(agent.getAddress());
|
||||
// if (Objects.isNull(session)){
|
||||
// throw new ApplicationException("流水线Agent断开连接,无法执行。");
|
||||
// }
|
||||
//
|
||||
// // 判断同一任务是否在运行
|
||||
// Pipeline pipeline = validExecPipeline(runMsg);
|
||||
// String pipelineId = pipeline.getId();
|
||||
// pipelineIdOrAgentId.put(pipelineId, agent);
|
||||
//
|
||||
// // 判断磁盘空间是否足够
|
||||
// diskService.validationStorageSpace();
|
||||
//
|
||||
// // 资源限制
|
||||
// resourcesService.judgeResources();
|
||||
//
|
||||
// // 进入执行
|
||||
// runMsg.setPipeline(pipeline);
|
||||
// runMsg.setAgent(agent);
|
||||
// return beginExecPipeline(runMsg);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 放入正在执行的流水线缓存中
|
||||
// * @param runMsg 流水线id
|
||||
// * @return 流水线信息
|
||||
// */
|
||||
// public Pipeline validExecPipeline(PipelineRunMsg runMsg){
|
||||
// String pipelineId = runMsg.getPipelineId();
|
||||
//
|
||||
// List<Stage> allMainStage = stageService.findAllMainStage(pipelineId);
|
||||
// if (allMainStage.isEmpty()){
|
||||
// throw new ApplicationException(2000,"当前流水线不存在可构建任务!");
|
||||
// }
|
||||
//
|
||||
// Boolean isVip = versionService.isVip();
|
||||
//
|
||||
// Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
//
|
||||
// int size = pipelineIdOrInstanceId.size();
|
||||
//
|
||||
// // 资源限制放入缓存中等待执行
|
||||
// if ((!isVip && size >= 2) || (isVip && size >= 4) ){
|
||||
// throw new ApplicationException(2000,"并行任务已满,等待执行!");
|
||||
// }
|
||||
// return pipeline;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 执行流水线
|
||||
// * @param runMsg 流水线信息
|
||||
// * @return 流水线实例
|
||||
// */
|
||||
// public PipelineInstance beginExecPipeline(PipelineRunMsg runMsg){
|
||||
// String pipelineId = runMsg.getPipelineId();
|
||||
// Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
// pipeline.setState(2);
|
||||
// pipelineService.updatePipeline(pipeline);
|
||||
// runMsg.setPipeline(pipeline);
|
||||
//
|
||||
// logger.info("流水线{}开始运行",pipeline.getName());
|
||||
// PipelineInstance pipelineInstance = pipelineInstanceService.initializeInstance(runMsg);
|
||||
// // 添加到缓存
|
||||
// String instanceId = pipelineInstance.getInstanceId();
|
||||
// pipelineInstanceService.instanceRuntime(pipelineInstance.getInstanceId());
|
||||
// joinTemplate.joinQuery(pipelineInstance);
|
||||
//
|
||||
// // 运行实例放入内存中
|
||||
// pipelineIdOrInstanceId.put(pipelineId, instanceId);
|
||||
//
|
||||
// try {
|
||||
// // 创建多阶段运行实例
|
||||
// List<Stage> stageList = stageExecService.createStageExecInstance(pipelineId, instanceId);
|
||||
//
|
||||
// List<Postprocess> postprocessList = postExecService.createPipelinePostInstance(pipelineId, instanceId);
|
||||
//
|
||||
// PipelineDetails pipelineDetails = new PipelineDetails();
|
||||
//
|
||||
// // 流水线基本运行信息
|
||||
// pipelineDetails.setPipelineId(pipelineId);
|
||||
// pipelineDetails.setInstanceId(instanceId);
|
||||
// pipelineDetails.setRunWay(runMsg.getRunWay());
|
||||
// pipelineDetails.setAgent(runMsg.getAgent());
|
||||
//
|
||||
// // 流水线运行任务
|
||||
// pipelineDetails.setStageList(stageList);
|
||||
//
|
||||
// // 流水线后置处理
|
||||
// pipelineDetails.setPostprocessList(postprocessList);
|
||||
//
|
||||
// // 数据路径,源码,日志保存
|
||||
// String sourceDir = utilService.findPipelineDefaultAddress(pipelineId,1);
|
||||
// String logDir = utilService.findPipelineDefaultAddress(pipelineId,2);
|
||||
// pipelineDetails.setSourceDir(sourceDir);
|
||||
// pipelineDetails.setLogDir(logDir);
|
||||
//
|
||||
// // 环境
|
||||
// List<Scm> scmList = scmService.findAllPipelineScm();
|
||||
// pipelineDetails.setScmList(scmList);
|
||||
//
|
||||
// // 变量
|
||||
// List<Variable> variableList = variableService.findAllVariable(pipelineId);
|
||||
// pipelineDetails.setVariableList(variableList);
|
||||
//
|
||||
// AgentMessage agentMessage = new AgentMessage();
|
||||
// agentMessage.setType("exec");
|
||||
// agentMessage.setMessage(pipelineDetails);
|
||||
// agentMessage.setPipelineId(pipelineId);
|
||||
//
|
||||
// Agent agent = pipelineDetails.getAgent();
|
||||
//
|
||||
// String id = agent.getAddress();
|
||||
//
|
||||
// WebSocketSession session = SocketServerHandler.sessionMap.get(id);
|
||||
// if (Objects.isNull(session)) {
|
||||
// throw new SystemException("客户端推送消息失败,无法获取客户端连接,客户端信息:"+id);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// SocketServerHandler.instance().sendHandleMessage(id,agentMessage);
|
||||
// } catch (Exception e) {
|
||||
// throw new SystemException("客户端推送消息失败,错误信息:" + e.getMessage());
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// logger.error("流水线执行出错了:{}",e.getMessage() );
|
||||
// stop(pipelineId);
|
||||
// }
|
||||
// return pipelineInstance;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void stop(String pipelineId){
|
||||
// Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
//
|
||||
// Agent agent = pipelineIdOrAgentId.get(pipelineId);
|
||||
// if (Objects.isNull(agent)){
|
||||
// pipeline.setState(1);
|
||||
// pipelineService.updatePipeline(pipeline);
|
||||
//
|
||||
// PipelineInstanceQuery pipelineInstanceQuery = new PipelineInstanceQuery();
|
||||
// pipelineInstanceQuery.setState(PipelineFinal.RUN_RUN);
|
||||
// pipelineInstanceQuery.setPipelineId(pipelineId);
|
||||
// List<PipelineInstance> pipelineInstanceList = pipelineInstanceService.findPipelineInstanceList(pipelineInstanceQuery);
|
||||
// for (PipelineInstance pipelineInstance : pipelineInstanceList) {
|
||||
// String instanceId = pipelineInstance.getInstanceId();
|
||||
// pipelineInstance.setRunStatus(PipelineFinal.RUN_HALT);
|
||||
// int runtime = pipelineInstanceService.findInstanceRuntime(instanceId);
|
||||
// pipelineInstance.setRunTime(runtime);
|
||||
// pipelineInstanceService.updateInstance(pipelineInstance);
|
||||
// }
|
||||
// removeExecCache(pipelineId);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// AgentMessage agentMessage = new AgentMessage();
|
||||
// agentMessage.setType("stop");
|
||||
// agentMessage.setMessage(pipelineId);
|
||||
// agentMessage.setPipelineId(pipelineId);
|
||||
// SocketServerHandler.instance().sendHandleMessage(agent.getAddress(),agentMessage);
|
||||
// }catch (Exception e){
|
||||
// logger.error(e.getMessage());
|
||||
// }
|
||||
//
|
||||
// // 添加资源配置
|
||||
// // resourcesService.instanceResources(integer);
|
||||
//
|
||||
// // 更新流水线状态
|
||||
// pipeline.setState(1);
|
||||
// pipelineService.updatePipeline(pipeline);
|
||||
//
|
||||
// PipelineInstanceQuery pipelineInstanceQuery = new PipelineInstanceQuery();
|
||||
// pipelineInstanceQuery.setState(PipelineFinal.RUN_RUN);
|
||||
// pipelineInstanceQuery.setPipelineId(pipelineId);
|
||||
// List<PipelineInstance> pipelineInstanceList = pipelineInstanceService.findPipelineInstanceList(pipelineInstanceQuery);
|
||||
// for (PipelineInstance pipelineInstance : pipelineInstanceList) {
|
||||
// pipelineInstance.setRunStatus(PipelineFinal.RUN_HALT);
|
||||
// int runtime = pipelineInstanceService.findInstanceRuntime(pipelineInstance.getInstanceId());
|
||||
// pipelineInstance.setRunTime(runtime);
|
||||
// pipelineInstanceService.updateInstance(pipelineInstance);
|
||||
// }
|
||||
// removeExecCache(pipelineId);
|
||||
// }
|
||||
//
|
||||
// public void removeExecCache(String pipelineId){
|
||||
// String instanceId = pipelineIdOrInstanceId.get(pipelineId);
|
||||
// PipelineInstanceServiceImpl.runTimeMap.remove(instanceId);
|
||||
// pipelineInstanceService.stopThread(instanceId);
|
||||
// pipelineIdOrInstanceId.remove(pipelineId);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void keepOn(String pipelineId){
|
||||
// Agent agent = pipelineIdOrAgentId.get(pipelineId);
|
||||
// String id = agent.getAddress();
|
||||
// AgentMessage agentMessage = new AgentMessage();
|
||||
// agentMessage.setType("keepOn");
|
||||
// agentMessage.setMessage(pipelineId);
|
||||
// agentMessage.setPipelineId(pipelineId);
|
||||
// WebSocketSession session = SocketServerHandler.sessionMap.get(id);
|
||||
// if (Objects.isNull(session)) {
|
||||
// throw new SystemException("客户端推送消息失败,无法获取客户端连接,客户端信息:"+id);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// SocketServerHandler.instance().sendHandleMessage(id,agentMessage);
|
||||
// } catch (Exception e) {
|
||||
// throw new SystemException("客户端推送消息失败,错误信息:" + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
package cd.casic.module.process.pipeline.execute.service.impl;
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.engine.execute.PipelineDetails;
|
||||
import cd.casic.ci.commons.bean.engine.execute.PipelineRunMsg;
|
||||
import cd.casic.ci.commons.bean.engine.postprocess.Postprocess;
|
||||
import cd.casic.ci.commons.bean.exception.SystemException;
|
||||
import cd.casic.ci.commons.bean.process.definition.Pipeline;
|
||||
import cd.casic.ci.commons.bean.process.definition.Variable;
|
||||
import cd.casic.ci.commons.bean.process.instance.PipelineInstance;
|
||||
import cd.casic.ci.commons.bean.process.instance.PipelineInstanceQuery;
|
||||
import cd.casic.ci.commons.bean.process.setting.Scm;
|
||||
import cd.casic.ci.commons.bean.process.stage.Stage;
|
||||
import cd.casic.ci.commons.bean.work.agent.AgentMessage;
|
||||
import cd.casic.ci.commons.bean.work.agent.model.Agent;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
import cd.casic.module.process.engine.task.TasksExecService;
|
||||
import cd.casic.module.process.pipeline.definition.PipelineService;
|
||||
import cd.casic.module.process.pipeline.execute.service.PipelineExecService;
|
||||
import cd.casic.module.process.pipeline.instance.service.PipelineInstanceServiceImpl;
|
||||
import cd.casic.module.process.process.definition.VariableService;
|
||||
import cd.casic.module.process.process.instance.PipelineInstanceService;
|
||||
import cd.casic.module.process.setting.service.ResourcesService;
|
||||
import cd.casic.module.process.setting.service.ScmService;
|
||||
import cd.casic.module.process.stages.service.StageExecService;
|
||||
import cd.casic.module.process.stages.service.StageService;
|
||||
import cd.casic.module.process.support.agent.service.AgentService;
|
||||
import cd.casic.module.process.support.disk.service.DiskService;
|
||||
import cd.casic.module.process.support.home.PipelineVersionService;
|
||||
import cd.casic.module.process.support.postprocess.service.PostprocessExecService;
|
||||
import cd.casic.module.process.support.util.PipelineUtilService;
|
||||
import cd.casic.module.process.support.util.util.PipelineFinal;
|
||||
import cd.casic.module.process.toolkit.join.JoinTemplate;
|
||||
import cd.casic.module.process.ws.server.SocketServerHandler;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
//import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 流水线运行服务
|
||||
*/
|
||||
@Service
|
||||
//@Exporter
|
||||
public class PipelineExecServiceImpl implements PipelineExecService {
|
||||
|
||||
@Autowired
|
||||
PipelineService pipelineService;
|
||||
|
||||
@Autowired
|
||||
PostprocessExecService postExecService;
|
||||
|
||||
@Autowired
|
||||
PipelineInstanceService pipelineInstanceService;
|
||||
|
||||
@Autowired
|
||||
TasksExecService tasksExecService;
|
||||
|
||||
@Autowired
|
||||
StageExecService stageExecService;
|
||||
|
||||
@Autowired
|
||||
ResourcesService resourcesService;
|
||||
|
||||
@Autowired
|
||||
PipelineVersionService versionService;
|
||||
|
||||
@Autowired
|
||||
PipelineUtilService utilService;
|
||||
|
||||
@Autowired
|
||||
DiskService diskService;
|
||||
|
||||
@Autowired
|
||||
StageService stageService;
|
||||
|
||||
@Autowired
|
||||
JoinTemplate joinTemplate;
|
||||
|
||||
@Autowired
|
||||
ScmService scmService;
|
||||
|
||||
@Autowired
|
||||
VariableService variableService;
|
||||
|
||||
@Autowired
|
||||
AgentService agentService;
|
||||
|
||||
public final Logger logger = LoggerFactory.getLogger(PipelineExecServiceImpl.class);
|
||||
|
||||
//流水线id:流水线实例id
|
||||
public static final Map<String,String> pipelineIdOrInstanceId = new HashMap<>();
|
||||
|
||||
//流水线id:agent
|
||||
public static final Map<String , Agent> pipelineIdOrAgentId = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 流水线开始运行
|
||||
* @param runMsg 流水线id
|
||||
* @return 是否正在运行
|
||||
*/
|
||||
@Override
|
||||
public PipelineInstance start(PipelineRunMsg runMsg) {
|
||||
Agent agent;
|
||||
if (StringUtils.isEmpty(runMsg.getAgentId())){
|
||||
agent = agentService.findDefaultAgent();
|
||||
}else {
|
||||
agent = agentService.findAgent(runMsg.getAgentId());
|
||||
}
|
||||
if (Objects.isNull(agent)){
|
||||
throw new ServiceException(GlobalErrorCodeConstants.LOCKED.getCode(),"无法获取到流水线执行Agent!");
|
||||
}
|
||||
|
||||
WebSocketSession session = SocketServerHandler.sessionMap.get(agent.getAddress());
|
||||
if (Objects.isNull(session)){
|
||||
throw new ServiceException(GlobalErrorCodeConstants.LOCKED.getCode(),"流水线Agent断开连接,无法执行。");
|
||||
}
|
||||
|
||||
// 判断同一任务是否在运行
|
||||
Pipeline pipeline = validExecPipeline(runMsg);
|
||||
String pipelineId = pipeline.getId();
|
||||
pipelineIdOrAgentId.put(pipelineId, agent);
|
||||
|
||||
// 判断磁盘空间是否足够
|
||||
diskService.validationStorageSpace();
|
||||
|
||||
// 资源限制
|
||||
resourcesService.judgeResources();
|
||||
|
||||
// 进入执行
|
||||
runMsg.setPipeline(pipeline);
|
||||
runMsg.setAgent(agent);
|
||||
return beginExecPipeline(runMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 放入正在执行的流水线缓存中
|
||||
* @param runMsg 流水线id
|
||||
* @return 流水线信息
|
||||
*/
|
||||
public Pipeline validExecPipeline(PipelineRunMsg runMsg){
|
||||
String pipelineId = runMsg.getPipelineId();
|
||||
|
||||
List<Stage> allMainStage = stageService.findAllMainStage(pipelineId);
|
||||
if (allMainStage.isEmpty()){
|
||||
throw new ServiceException(2000,"当前流水线不存在可构建任务!");
|
||||
}
|
||||
|
||||
Boolean isVip = versionService.isVip();
|
||||
|
||||
Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
|
||||
int size = pipelineIdOrInstanceId.size();
|
||||
|
||||
// 资源限制放入缓存中等待执行
|
||||
if ((!isVip && size >= 2) || (isVip && size >= 4) ){
|
||||
throw new ServiceException(2000,"并行任务已满,等待执行!");
|
||||
}
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行流水线
|
||||
* @param runMsg 流水线信息
|
||||
* @return 流水线实例
|
||||
*/
|
||||
public PipelineInstance beginExecPipeline(PipelineRunMsg runMsg){
|
||||
String pipelineId = runMsg.getPipelineId();
|
||||
Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
pipeline.setState(2);
|
||||
pipelineService.updatePipeline(pipeline);
|
||||
runMsg.setPipeline(pipeline);
|
||||
|
||||
logger.info("流水线{}开始运行",pipeline.getName());
|
||||
PipelineInstance pipelineInstance = pipelineInstanceService.initializeInstance(runMsg);
|
||||
// 添加到缓存
|
||||
String instanceId = pipelineInstance.getInstanceId();
|
||||
pipelineInstanceService.instanceRuntime(pipelineInstance.getInstanceId());
|
||||
joinTemplate.joinQuery(pipelineInstance);
|
||||
|
||||
// 运行实例放入内存中
|
||||
pipelineIdOrInstanceId.put(pipelineId, instanceId);
|
||||
|
||||
try {
|
||||
// 创建多阶段运行实例
|
||||
List<Stage> stageList = stageExecService.createStageExecInstance(pipelineId, instanceId);
|
||||
|
||||
List<Postprocess> postprocessList = postExecService.createPipelinePostInstance(pipelineId, instanceId);
|
||||
|
||||
PipelineDetails pipelineDetails = new PipelineDetails();
|
||||
|
||||
// 流水线基本运行信息
|
||||
pipelineDetails.setPipelineId(pipelineId);
|
||||
pipelineDetails.setInstanceId(instanceId);
|
||||
pipelineDetails.setRunWay(runMsg.getRunWay());
|
||||
pipelineDetails.setAgent(runMsg.getAgent());
|
||||
|
||||
// 流水线运行任务
|
||||
pipelineDetails.setStageList(stageList);
|
||||
|
||||
// 流水线后置处理
|
||||
pipelineDetails.setPostprocessList(postprocessList);
|
||||
|
||||
// 数据路径,源码,日志保存
|
||||
String sourceDir = utilService.findPipelineDefaultAddress(pipelineId,1);
|
||||
String logDir = utilService.findPipelineDefaultAddress(pipelineId,2);
|
||||
pipelineDetails.setSourceDir(sourceDir);
|
||||
pipelineDetails.setLogDir(logDir);
|
||||
|
||||
// 环境
|
||||
List<Scm> scmList = scmService.findAllPipelineScm();
|
||||
pipelineDetails.setScmList(scmList);
|
||||
|
||||
// 变量
|
||||
List<Variable> variableList = variableService.findAllVariable(pipelineId);
|
||||
pipelineDetails.setVariableList(variableList);
|
||||
|
||||
AgentMessage agentMessage = new AgentMessage();
|
||||
agentMessage.setType("exec");
|
||||
agentMessage.setMessage(pipelineDetails);
|
||||
agentMessage.setPipelineId(pipelineId);
|
||||
|
||||
Agent agent = pipelineDetails.getAgent();
|
||||
|
||||
String id = agent.getAddress();
|
||||
|
||||
WebSocketSession session = SocketServerHandler.sessionMap.get(id);
|
||||
if (Objects.isNull(session)) {
|
||||
throw new SystemException("客户端推送消息失败,无法获取客户端连接,客户端信息:"+id);
|
||||
}
|
||||
|
||||
try {
|
||||
SocketServerHandler.instance().sendHandleMessage(id,agentMessage);
|
||||
} catch (Exception e) {
|
||||
throw new SystemException("客户端推送消息失败,错误信息:" + e.getMessage());
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("流水线执行出错了:{}",e.getMessage() );
|
||||
stop(pipelineId);
|
||||
}
|
||||
return pipelineInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(String pipelineId){
|
||||
Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
|
||||
Agent agent = pipelineIdOrAgentId.get(pipelineId);
|
||||
if (Objects.isNull(agent)){
|
||||
pipeline.setState(1);
|
||||
pipelineService.updatePipeline(pipeline);
|
||||
|
||||
PipelineInstanceQuery pipelineInstanceQuery = new PipelineInstanceQuery();
|
||||
pipelineInstanceQuery.setState(PipelineFinal.RUN_RUN);
|
||||
pipelineInstanceQuery.setPipelineId(pipelineId);
|
||||
List<PipelineInstance> pipelineInstanceList = pipelineInstanceService.findPipelineInstanceList(pipelineInstanceQuery);
|
||||
for (PipelineInstance pipelineInstance : pipelineInstanceList) {
|
||||
String instanceId = pipelineInstance.getInstanceId();
|
||||
pipelineInstance.setRunStatus(PipelineFinal.RUN_HALT);
|
||||
int runtime = pipelineInstanceService.findInstanceRuntime(instanceId);
|
||||
pipelineInstance.setRunTime(runtime);
|
||||
pipelineInstanceService.updateInstance(pipelineInstance);
|
||||
}
|
||||
removeExecCache(pipelineId);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
AgentMessage agentMessage = new AgentMessage();
|
||||
agentMessage.setType("stop");
|
||||
agentMessage.setMessage(pipelineId);
|
||||
agentMessage.setPipelineId(pipelineId);
|
||||
SocketServerHandler.instance().sendHandleMessage(agent.getAddress(),agentMessage);
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
// 添加资源配置
|
||||
// resourcesService.instanceResources(integer);
|
||||
|
||||
// 更新流水线状态
|
||||
pipeline.setState(1);
|
||||
pipelineService.updatePipeline(pipeline);
|
||||
|
||||
PipelineInstanceQuery pipelineInstanceQuery = new PipelineInstanceQuery();
|
||||
pipelineInstanceQuery.setState(PipelineFinal.RUN_RUN);
|
||||
pipelineInstanceQuery.setPipelineId(pipelineId);
|
||||
List<PipelineInstance> pipelineInstanceList = pipelineInstanceService.findPipelineInstanceList(pipelineInstanceQuery);
|
||||
for (PipelineInstance pipelineInstance : pipelineInstanceList) {
|
||||
pipelineInstance.setRunStatus(PipelineFinal.RUN_HALT);
|
||||
int runtime = pipelineInstanceService.findInstanceRuntime(pipelineInstance.getInstanceId());
|
||||
pipelineInstance.setRunTime(runtime);
|
||||
pipelineInstanceService.updateInstance(pipelineInstance);
|
||||
}
|
||||
removeExecCache(pipelineId);
|
||||
}
|
||||
|
||||
public void removeExecCache(String pipelineId){
|
||||
String instanceId = pipelineIdOrInstanceId.get(pipelineId);
|
||||
PipelineInstanceServiceImpl.runTimeMap.remove(instanceId);
|
||||
pipelineInstanceService.stopThread(instanceId);
|
||||
pipelineIdOrInstanceId.remove(pipelineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keepOn(String pipelineId){
|
||||
Agent agent = pipelineIdOrAgentId.get(pipelineId);
|
||||
String id = agent.getAddress();
|
||||
AgentMessage agentMessage = new AgentMessage();
|
||||
agentMessage.setType("keepOn");
|
||||
agentMessage.setMessage(pipelineId);
|
||||
agentMessage.setPipelineId(pipelineId);
|
||||
WebSocketSession session = SocketServerHandler.sessionMap.get(id);
|
||||
if (Objects.isNull(session)) {
|
||||
throw new SystemException("客户端推送消息失败,无法获取客户端连接,客户端信息:"+id);
|
||||
}
|
||||
|
||||
try {
|
||||
SocketServerHandler.instance().sendHandleMessage(id,agentMessage);
|
||||
} catch (Exception e) {
|
||||
throw new SystemException("客户端推送消息失败,错误信息:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
package cd.casic.module.process.task.artifact.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 任务推送制品模型
|
||||
*/
|
||||
//@ApiModel
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class TaskArtifact {
|
||||
|
||||
//@ApiProperty(name = "taskId",desc = "id")
|
||||
private String taskId;
|
||||
|
||||
//@ApiProperty(name = "groupId",desc = "groupId")
|
||||
private String groupId;
|
||||
|
||||
//@ApiProperty(name = "artifactId",desc = "artifactId")
|
||||
private String artifactId;
|
||||
|
||||
//@ApiProperty(name = "artifactType",desc = "推送类型")
|
||||
private String artifactType;
|
||||
|
||||
//@ApiProperty(name = "version",desc = "version")
|
||||
private String version;
|
||||
|
||||
//@ApiProperty(name = "fileType",desc = "文件类型")
|
||||
private String fileType;
|
||||
|
||||
//@ApiProperty(name = "fileAddress",desc = "文件地址")
|
||||
private String fileAddress;
|
||||
|
||||
//@ApiProperty(name = "putAddress",desc = "发送地址")
|
||||
private String putAddress;
|
||||
|
||||
//@ApiProperty(name = "dockerImage",desc = "docker镜像")
|
||||
private String dockerImage;
|
||||
|
||||
//授权id
|
||||
//@ApiProperty(name="authId",desc="授权id")
|
||||
private String authId;
|
||||
|
||||
//@ApiProperty(name="authId",desc="rule")
|
||||
private String rule;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "repository.id",target = "xpackId")
|
||||
// })
|
||||
// @JoinQuery(key = "xpackId")
|
||||
private XpackRepository repository;
|
||||
|
||||
//授权信息
|
||||
private Object auth;
|
||||
|
||||
private String type;
|
||||
|
||||
private int sort;
|
||||
|
||||
private String instanceId;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cd.casic.module.process.task.artifact.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class XpackRepository {
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
private String repositoryUrl;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cd.casic.module.process.task.artifact.model;
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class XpackRepositoryQuery {
|
||||
|
||||
// @ApiProperty(name = "orderParams", desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().asc("id").get();
|
||||
|
||||
// @ApiProperty(name = "pageParam", desc = "分页参数")
|
||||
private PageParam pageParam = new PageParam();
|
||||
|
||||
// @ApiProperty(name = "name", desc = "制品库名字")
|
||||
private String name;
|
||||
|
||||
// @ApiProperty(name = "repositoryType", desc = "制品库类型 maven、npm")
|
||||
private String repositoryType;
|
||||
|
||||
// @ApiProperty(name = "type", desc = "类型 local、remote、group")
|
||||
private String type;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cd.casic.module.process.task.artifact.service;
|
||||
|
||||
import cd.casic.module.process.task.artifact.model.XpackRepository;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TaskArtifactXpackService {
|
||||
|
||||
/**
|
||||
* 获取xpack仓库
|
||||
* @param authId 认证id
|
||||
* @return 仓库
|
||||
*/
|
||||
List<XpackRepository> findAllRepository(String authId);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param authId 认证id
|
||||
* @param rpyId 仓库id
|
||||
* @return 仓库地址
|
||||
*/
|
||||
XpackRepository findRepository(String authId,String rpyId);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cd.casic.module.process.task.build.model;
|
||||
|
||||
|
||||
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||
import io.tiklab.toolkit.join.annotation.Join;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 任务构建模型
|
||||
*/
|
||||
//@ApiModel
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class TaskBuild {
|
||||
|
||||
//@ApiProperty(name = "taskId",desc = "id")
|
||||
private String taskId;
|
||||
|
||||
//构建文件地址
|
||||
//@ApiProperty(name="buildAddress",desc="构建文件地址")
|
||||
private String buildAddress;
|
||||
|
||||
//构建命令
|
||||
//@ApiProperty(name="buildOrder",desc="构建命令")
|
||||
private String buildOrder;
|
||||
|
||||
//@ApiProperty(name="productRule",desc="制品规则")
|
||||
private String productRule;
|
||||
|
||||
|
||||
//@ApiProperty(name = "dockerName",desc="镜像名称")
|
||||
private String dockerName;
|
||||
|
||||
//@ApiProperty(name = "dockerVersion",desc="镜像版本")
|
||||
private String dockerVersion;
|
||||
|
||||
//@ApiProperty(name = "dockerFile",desc="DockerFile文件地址")
|
||||
private String dockerFile;
|
||||
|
||||
//@ApiProperty(name = "dockerOrder",desc="Docker部署命令")
|
||||
private String dockerOrder;
|
||||
|
||||
//顺序
|
||||
private int sort;
|
||||
|
||||
//构建类型
|
||||
private String type;
|
||||
|
||||
private String instanceId;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cd.casic.module.process.task.code.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 任务源码模型
|
||||
*/
|
||||
//@ApiModel
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class TaskCode {
|
||||
|
||||
//@ApiProperty(name = "taskId",desc = "id")
|
||||
private String taskId;
|
||||
|
||||
//地址名
|
||||
//@ApiProperty(name="codeName",desc="地址名")
|
||||
private String codeName;
|
||||
|
||||
//代码源地址
|
||||
//@ApiProperty(name="codeAddress",desc="代码地址")
|
||||
private String codeAddress;
|
||||
|
||||
//分支
|
||||
//@ApiProperty(name="codeBranch",desc="分支")
|
||||
private String codeBranch;
|
||||
|
||||
//授权id
|
||||
//@ApiProperty(name="authId",desc="授权id")
|
||||
private String authId;
|
||||
|
||||
//@ApiProperty(name="svnFile",desc="svn检出文件夹")
|
||||
private String svnFile;
|
||||
|
||||
// 第三方仓库ID
|
||||
private String houseId;
|
||||
|
||||
|
||||
//授权信息
|
||||
private Object auth;
|
||||
|
||||
//顺序
|
||||
private int sort;
|
||||
|
||||
//代码类型
|
||||
private String type;
|
||||
|
||||
private String instanceId;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cd.casic.module.process.task.code.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
//import io.tiklab.core.BaseModel;
|
||||
@Data
|
||||
public class ThirdBranch {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Boolean isProtected = false ;
|
||||
|
||||
private Boolean isDefault;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cd.casic.module.process.task.code.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
//import io.tiklab.core.BaseModel;
|
||||
@Data
|
||||
public class ThirdHouse {
|
||||
|
||||
private String id;
|
||||
|
||||
private String path;
|
||||
|
||||
private String name;
|
||||
|
||||
private String pathWithSpace;
|
||||
|
||||
private String nameWithSpace;
|
||||
|
||||
private String houseWebUrl;
|
||||
|
||||
private String houseSshUrl;
|
||||
|
||||
private String defaultBranch;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cd.casic.module.process.task.code.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
//import io.tiklab.core.BaseModel;
|
||||
@Data
|
||||
public class ThirdQuery {
|
||||
|
||||
private String authId;
|
||||
|
||||
private String houseId;
|
||||
|
||||
// 查询条件
|
||||
private String query;
|
||||
|
||||
// 页数
|
||||
private Integer page = 1;
|
||||
|
||||
// 每页数量
|
||||
private Integer pageNumber = 50;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cd.casic.module.process.task.code.model;
|
||||
|
||||
//import io.tiklab.core.BaseModel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ThirdUser {
|
||||
|
||||
private String id;
|
||||
|
||||
private String path;
|
||||
|
||||
private String name;
|
||||
|
||||
private String head;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cd.casic.module.process.task.code.service;
|
||||
|
||||
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.module.process.task.codescan.model.SpotbugsBugQuery;
|
||||
import cd.casic.module.process.task.codescan.model.SpotbugsBugSummary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public interface SpotbugsScanService {
|
||||
|
||||
|
||||
String creatSpotbugs(SpotbugsBugSummary bugSummary);
|
||||
|
||||
|
||||
void updateSpotbugs(SpotbugsBugSummary bugSummary);
|
||||
|
||||
|
||||
void deleteSpotbugs(String bugId);
|
||||
|
||||
SpotbugsBugSummary findOneSpotbugs(String bugId);
|
||||
|
||||
|
||||
List<SpotbugsBugSummary> findAllSpotbugs();
|
||||
|
||||
|
||||
List<SpotbugsBugSummary> findSpotbugsList(SpotbugsBugQuery bugQuery);
|
||||
|
||||
|
||||
PageResult<SpotbugsBugSummary> findSpotbugsPage(SpotbugsBugQuery bugQuery);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cd.casic.module.process.task.code.service;
|
||||
|
||||
|
||||
|
||||
|
||||
import cd.casic.module.process.task.code.model.ThirdBranch;
|
||||
import cd.casic.module.process.task.code.model.ThirdHouse;
|
||||
import cd.casic.module.process.task.code.model.ThirdQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TaskCodeGittokService {
|
||||
|
||||
/**
|
||||
* 获取凭证认证的仓库列表
|
||||
* @param thirdQuery 凭证
|
||||
* @return 仓库列表
|
||||
*/
|
||||
List<ThirdHouse> findStoreHouseList(ThirdQuery thirdQuery);
|
||||
|
||||
/**
|
||||
* 获取凭证认证的仓库分支列表
|
||||
* @param thirdQuery 凭证
|
||||
* @return 分支列表
|
||||
*/
|
||||
List<ThirdBranch> findHouseBranchList(ThirdQuery thirdQuery);
|
||||
|
||||
|
||||
/**
|
||||
* 获取分支
|
||||
* @param authId 认证id
|
||||
* @param rpyId 仓库id
|
||||
* @param branchId 分支id
|
||||
* @return 分支
|
||||
*/
|
||||
ThirdBranch findOneBranch(String authId,String rpyId,String branchId);
|
||||
|
||||
/**
|
||||
* 获取凭证认证的指定的仓库
|
||||
* @param thirdQuery 凭证
|
||||
* @return 指定的仓库
|
||||
*/
|
||||
ThirdHouse findStoreHouse(ThirdQuery thirdQuery);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author Spotbugs代码扫描
|
||||
*/
|
||||
public class SpotbugsBugCategory {
|
||||
|
||||
|
||||
// bug描述
|
||||
private String category;
|
||||
|
||||
private String description;
|
||||
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public SpotbugsBugCategory setCategory(String category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public SpotbugsBugCategory setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugClass {
|
||||
|
||||
|
||||
private String classname;
|
||||
|
||||
private int startLine;
|
||||
|
||||
private int endLine;
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
public String getClassname() {
|
||||
return classname;
|
||||
}
|
||||
|
||||
public SpotbugsBugClass setClassname(String classname) {
|
||||
this.classname = classname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getStartLine() {
|
||||
return startLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugClass setStartLine(int startLine) {
|
||||
this.startLine = startLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getEndLine() {
|
||||
return endLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugClass setEndLine(int endLine) {
|
||||
this.endLine = endLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public SpotbugsBugClass setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugClassStats {
|
||||
|
||||
private String className;
|
||||
|
||||
private String classPath;
|
||||
|
||||
private int bugNumber;
|
||||
|
||||
private Boolean isInterface;
|
||||
|
||||
private List<SpotbugsBugInstance> bugInstanceList;
|
||||
|
||||
public List<SpotbugsBugInstance> getBugInstanceList() {
|
||||
return bugInstanceList;
|
||||
}
|
||||
|
||||
public SpotbugsBugClassStats setBugInstanceList(List<SpotbugsBugInstance> bugInstanceList) {
|
||||
this.bugInstanceList = bugInstanceList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public SpotbugsBugClassStats setClassName(String className) {
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getClassPath() {
|
||||
return classPath;
|
||||
}
|
||||
|
||||
public SpotbugsBugClassStats setClassPath(String classPath) {
|
||||
this.classPath = classPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getBugNumber() {
|
||||
return bugNumber;
|
||||
}
|
||||
|
||||
public SpotbugsBugClassStats setBugNumber(int bugNumber) {
|
||||
this.bugNumber = bugNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getInterface() {
|
||||
return isInterface;
|
||||
}
|
||||
|
||||
public SpotbugsBugClassStats setInterface(Boolean anInterface) {
|
||||
isInterface = anInterface;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugCode {
|
||||
|
||||
private String abbrev;
|
||||
|
||||
|
||||
private String cweid;
|
||||
|
||||
private String description;
|
||||
|
||||
public String getAbbrev() {
|
||||
return abbrev;
|
||||
}
|
||||
|
||||
public SpotbugsBugCode setAbbrev(String abbrev) {
|
||||
this.abbrev = abbrev;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCweid() {
|
||||
return cweid;
|
||||
}
|
||||
|
||||
public SpotbugsBugCode setCweid(String cweid) {
|
||||
this.cweid = cweid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public SpotbugsBugCode setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugField {
|
||||
|
||||
|
||||
private String fieldName;
|
||||
|
||||
private String signature;
|
||||
|
||||
private String message;
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public SpotbugsBugField setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public SpotbugsBugField setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public SpotbugsBugField setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 文件代码bug信息
|
||||
*/
|
||||
public class SpotbugsBugFileStats {
|
||||
|
||||
private String path;
|
||||
|
||||
private String bugNumber;
|
||||
|
||||
private List<SpotbugsBugInstance> bugInstanceList;
|
||||
|
||||
public List<SpotbugsBugInstance> getBugInstanceList() {
|
||||
return bugInstanceList;
|
||||
}
|
||||
|
||||
public SpotbugsBugFileStats setBugInstanceList(List<SpotbugsBugInstance> bugInstanceList) {
|
||||
this.bugInstanceList = bugInstanceList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public SpotbugsBugFileStats setPath(String path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBugNumber() {
|
||||
return bugNumber;
|
||||
}
|
||||
|
||||
public SpotbugsBugFileStats setBugNumber(String bugNumber) {
|
||||
this.bugNumber = bugNumber;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author Spotbugs代码扫描,Bug实例
|
||||
*/
|
||||
public class SpotbugsBugInstance {
|
||||
|
||||
// bug类型
|
||||
private String bugType;
|
||||
|
||||
// bug级别
|
||||
private String bugPriority;
|
||||
|
||||
// 简略描述
|
||||
private String shortMessage;
|
||||
|
||||
// 详细描述
|
||||
private String longMessage;
|
||||
|
||||
// bug类描述
|
||||
private SpotbugsBugClass bugClass;
|
||||
|
||||
// bug字段描述
|
||||
private SpotbugsBugField bugField;
|
||||
|
||||
// bug方法描述
|
||||
private SpotbugsBugMethod bugMethod;
|
||||
|
||||
// bug源码描述
|
||||
private SpotbugsBugSourceLine bugSourceLine;
|
||||
|
||||
// 表示一个Bug的类别
|
||||
private SpotbugsBugCategory category;
|
||||
|
||||
// 代码缺陷模式(BugPattern)的信息
|
||||
private SpotbugsBugPattern bugPattern;
|
||||
|
||||
// 表示一个Bug的类型
|
||||
private SpotbugsBugCode bugCode;
|
||||
|
||||
|
||||
public String getBugType() {
|
||||
return bugType;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugType(String bugType) {
|
||||
this.bugType = bugType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBugPriority() {
|
||||
return bugPriority;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugPriority(String bugPriority) {
|
||||
this.bugPriority = bugPriority;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getShortMessage() {
|
||||
return shortMessage;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setShortMessage(String shortMessage) {
|
||||
this.shortMessage = shortMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLongMessage() {
|
||||
return longMessage;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setLongMessage(String longMessage) {
|
||||
this.longMessage = longMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugClass getBugClass() {
|
||||
return bugClass;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugClass(SpotbugsBugClass bugClass) {
|
||||
this.bugClass = bugClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugField getBugField() {
|
||||
return bugField;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugField(SpotbugsBugField bugField) {
|
||||
this.bugField = bugField;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugMethod getBugMethod() {
|
||||
return bugMethod;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugMethod(SpotbugsBugMethod bugMethod) {
|
||||
this.bugMethod = bugMethod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugSourceLine getBugSourceLine() {
|
||||
return bugSourceLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugSourceLine(SpotbugsBugSourceLine bugSourceLine) {
|
||||
this.bugSourceLine = bugSourceLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setCategory(SpotbugsBugCategory category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugPattern getBugPattern() {
|
||||
return bugPattern;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugPattern(SpotbugsBugPattern bugPattern) {
|
||||
this.bugPattern = bugPattern;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpotbugsBugCode getBugCode() {
|
||||
return bugCode;
|
||||
}
|
||||
|
||||
public SpotbugsBugInstance setBugCode(SpotbugsBugCode bugCode) {
|
||||
this.bugCode = bugCode;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugMethod {
|
||||
|
||||
private String methodName;
|
||||
|
||||
private String signature;
|
||||
|
||||
private int startLine;
|
||||
|
||||
private int endLine;
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public SpotbugsBugMethod setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public SpotbugsBugMethod setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getStartLine() {
|
||||
return startLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugMethod setStartLine(int startLine) {
|
||||
this.startLine = startLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getEndLine() {
|
||||
return endLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugMethod setEndLine(int endLine) {
|
||||
this.endLine = endLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public SpotbugsBugMethod setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugPackageStats {
|
||||
|
||||
private String packagePath;
|
||||
|
||||
private int totalBugs;
|
||||
|
||||
|
||||
private int totalTypes;
|
||||
|
||||
private List<SpotbugsBugClassStats> classStatsList;
|
||||
|
||||
|
||||
public String getPackagePath() {
|
||||
return packagePath;
|
||||
}
|
||||
|
||||
public SpotbugsBugPackageStats setPackagePath(String packagePath) {
|
||||
this.packagePath = packagePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTotalBugs() {
|
||||
return totalBugs;
|
||||
}
|
||||
|
||||
public SpotbugsBugPackageStats setTotalBugs(int totalBugs) {
|
||||
this.totalBugs = totalBugs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTotalTypes() {
|
||||
return totalTypes;
|
||||
}
|
||||
|
||||
public SpotbugsBugPackageStats setTotalTypes(int totalTypes) {
|
||||
this.totalTypes = totalTypes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<SpotbugsBugClassStats> getClassStatsList() {
|
||||
return classStatsList;
|
||||
}
|
||||
|
||||
public SpotbugsBugPackageStats setClassStatsList(List<SpotbugsBugClassStats> classStatsList) {
|
||||
this.classStatsList = classStatsList;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugPattern {
|
||||
|
||||
private String type;
|
||||
|
||||
private String abbrev;
|
||||
|
||||
private String category;
|
||||
|
||||
|
||||
private String shortDescription;
|
||||
|
||||
private String details;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public SpotbugsBugPattern setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAbbrev() {
|
||||
return abbrev;
|
||||
}
|
||||
|
||||
public SpotbugsBugPattern setAbbrev(String abbrev) {
|
||||
this.abbrev = abbrev;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public SpotbugsBugPattern setCategory(String category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return shortDescription;
|
||||
}
|
||||
|
||||
public SpotbugsBugPattern setShortDescription(String shortDescription) {
|
||||
this.shortDescription = shortDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public SpotbugsBugPattern setDetails(String details) {
|
||||
this.details = details;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
import io.tiklab.core.order.Order;
|
||||
import io.tiklab.core.order.OrderBuilders;
|
||||
import io.tiklab.core.page.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代码扫描查询
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugQuery {
|
||||
|
||||
private String pipelineId;
|
||||
|
||||
private Page pageParam= new Page();
|
||||
|
||||
private List<Order> orderParams = OrderBuilders.instance().desc("scanTime").get();
|
||||
|
||||
public List<Order> getOrderParams() {
|
||||
return orderParams;
|
||||
}
|
||||
|
||||
public SpotbugsBugQuery setOrderParams(List<Order> orderParams) {
|
||||
this.orderParams = orderParams;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Page getPageParam() {
|
||||
return pageParam;
|
||||
}
|
||||
|
||||
public SpotbugsBugQuery setPageParam(Page pageParam) {
|
||||
this.pageParam = pageParam;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPipelineId() {
|
||||
return pipelineId;
|
||||
}
|
||||
|
||||
public SpotbugsBugQuery setPipelineId(String pipelineId) {
|
||||
this.pipelineId = pipelineId;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
/**
|
||||
* @author zcamy
|
||||
*/
|
||||
public class SpotbugsBugSourceLine {
|
||||
|
||||
|
||||
private String sourcePath;
|
||||
|
||||
|
||||
private String sourceFile;
|
||||
|
||||
private int startLine;
|
||||
|
||||
private int endLine;
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
public String getSourcePath() {
|
||||
return sourcePath;
|
||||
}
|
||||
|
||||
public SpotbugsBugSourceLine setSourcePath(String sourcePath) {
|
||||
this.sourcePath = sourcePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSourceFile() {
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
public SpotbugsBugSourceLine setSourceFile(String sourceFile) {
|
||||
this.sourceFile = sourceFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getStartLine() {
|
||||
return startLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugSourceLine setStartLine(int startLine) {
|
||||
this.startLine = startLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getEndLine() {
|
||||
return endLine;
|
||||
}
|
||||
|
||||
public SpotbugsBugSourceLine setEndLine(int endLine) {
|
||||
this.endLine = endLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public SpotbugsBugSourceLine setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||
import io.tiklab.toolkit.join.annotation.Join;
|
||||
|
||||
/**
|
||||
* @author Spotbugs代码扫描信息
|
||||
*/
|
||||
@Join
|
||||
@Mapper(targetName = "io.tiklab.arbess.task.codescan.entity.SpotbugsScanEntity")
|
||||
// @Mapper
|
||||
public class SpotbugsBugSummary {
|
||||
|
||||
// id
|
||||
private String id;
|
||||
|
||||
// 流水线id
|
||||
private String pipelineId;
|
||||
|
||||
// 扫描时间
|
||||
private String scanTime;
|
||||
|
||||
// 总共扫描的类的数量。
|
||||
private String totalClasses;
|
||||
|
||||
// 引用的类的数量
|
||||
private String referencedClasses;
|
||||
|
||||
// 检测到的问题(Bugs)的数量
|
||||
private String totalBugs;
|
||||
|
||||
// 项目中的包(package)数量
|
||||
private String numPackages;
|
||||
|
||||
// Java 版本信息
|
||||
private String vmVersion;
|
||||
|
||||
// 优先级为 1 的问题数
|
||||
private String priorityOne;
|
||||
|
||||
// 优先级为 2 的问题数
|
||||
private String priorityTwo;
|
||||
|
||||
// 优先级为 3 的问题数
|
||||
private String priorityThree;
|
||||
|
||||
// xml文件报错地址
|
||||
private String xmlPath;
|
||||
|
||||
// xml文件内容
|
||||
private String xmlFileContent;
|
||||
|
||||
public String getXmlFileContent() {
|
||||
return xmlFileContent;
|
||||
}
|
||||
|
||||
public void setXmlFileContent(String xmlFileContent) {
|
||||
this.xmlFileContent = xmlFileContent;
|
||||
}
|
||||
|
||||
public String getXmlPath() {
|
||||
return xmlPath;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setXmlPath(String xmlPath) {
|
||||
this.xmlPath = xmlPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getVmVersion() {
|
||||
return vmVersion;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setVmVersion(String vmVersion) {
|
||||
this.vmVersion = vmVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPipelineId() {
|
||||
return pipelineId;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setPipelineId(String pipelineId) {
|
||||
this.pipelineId = pipelineId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getScanTime() {
|
||||
return scanTime;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setScanTime(String scanTime) {
|
||||
this.scanTime = scanTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTotalClasses() {
|
||||
return totalClasses;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setTotalClasses(String totalClasses) {
|
||||
this.totalClasses = totalClasses;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getReferencedClasses() {
|
||||
return referencedClasses;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setReferencedClasses(String referencedClasses) {
|
||||
this.referencedClasses = referencedClasses;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTotalBugs() {
|
||||
return totalBugs;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setTotalBugs(String totalBugs) {
|
||||
this.totalBugs = totalBugs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNumPackages() {
|
||||
return numPackages;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setNumPackages(String numPackages) {
|
||||
this.numPackages = numPackages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPriorityOne() {
|
||||
return priorityOne;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setPriorityOne(String priorityOne) {
|
||||
this.priorityOne = priorityOne;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPriorityTwo() {
|
||||
return priorityTwo;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setPriorityTwo(String priorityTwo) {
|
||||
this.priorityTwo = priorityTwo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPriorityThree() {
|
||||
return priorityThree;
|
||||
}
|
||||
|
||||
public SpotbugsBugSummary setPriorityThree(String priorityThree) {
|
||||
this.priorityThree = priorityThree;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package cd.casic.module.process.task.codescan.model;
|
||||
|
||||
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||
import io.tiklab.toolkit.join.annotation.Join;
|
||||
|
||||
|
||||
/**
|
||||
* 任务代码扫描模型
|
||||
*/
|
||||
//@ApiModel
|
||||
@Join
|
||||
@Mapper
|
||||
public class TaskCodeScan {
|
||||
|
||||
//@ApiProperty(name = "taskId",desc = "id")
|
||||
private String taskId;
|
||||
|
||||
//@ApiProperty(name="projectName",desc="项目名称")
|
||||
private String projectName;
|
||||
|
||||
//授权id
|
||||
//@ApiProperty(name="authName",desc="授权id")
|
||||
private String authId;
|
||||
|
||||
|
||||
// 是否开启断言
|
||||
private Boolean openAssert;
|
||||
|
||||
// 是否启用调试模式
|
||||
private Boolean openDebug;
|
||||
|
||||
// 扫描路径
|
||||
private String scanPath;
|
||||
|
||||
// 扫描等级 min--最小,default--默认,max--最大
|
||||
private String scanGrade;
|
||||
|
||||
// 扫描错误级别 default--默认 max--最大
|
||||
private String errGrade;
|
||||
|
||||
//授权信息
|
||||
private Object auth;
|
||||
|
||||
private int sort;
|
||||
|
||||
private String type;
|
||||
|
||||
private String instanceId;
|
||||
|
||||
public String getInstanceId() {
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
public void setInstanceId(String instanceId) {
|
||||
this.instanceId = instanceId;
|
||||
}
|
||||
|
||||
public String getScanGrade() {
|
||||
return scanGrade;
|
||||
}
|
||||
|
||||
public TaskCodeScan setScanGrade(String scanGrade) {
|
||||
this.scanGrade = scanGrade;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getErrGrade() {
|
||||
return errGrade;
|
||||
}
|
||||
|
||||
public TaskCodeScan setErrGrade(String errGrade) {
|
||||
this.errGrade = errGrade;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getScanPath() {
|
||||
return scanPath;
|
||||
}
|
||||
|
||||
public TaskCodeScan setScanPath(String scanPath) {
|
||||
this.scanPath = scanPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getOpenAssert() {
|
||||
return openAssert;
|
||||
}
|
||||
|
||||
public TaskCodeScan setOpenAssert(Boolean openAssert) {
|
||||
this.openAssert = openAssert;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getOpenDebug() {
|
||||
return openDebug;
|
||||
}
|
||||
|
||||
public TaskCodeScan setOpenDebug(Boolean openDebug) {
|
||||
this.openDebug = openDebug;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(int sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getAuthId() {
|
||||
return authId;
|
||||
}
|
||||
|
||||
public void setAuthId(String authId) {
|
||||
this.authId = authId;
|
||||
}
|
||||
|
||||
public Object getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public void setAuth(Object auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cd.casic.module.process.task.codescan.service;
|
||||
|
||||
|
||||
import cd.casic.module.process.task.codescan.model.TaskCodeScan;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 代码扫描服务接口
|
||||
*/
|
||||
//@JoinProvider(model = TaskCodeScan.class)
|
||||
public interface TaskCodeScanService {
|
||||
|
||||
/**
|
||||
* 创建流水线代码扫描
|
||||
* @param taskCodeScan 流水线代码扫描
|
||||
* @return 流水线代码扫描id
|
||||
*/
|
||||
String createCodeScan(TaskCodeScan taskCodeScan);
|
||||
|
||||
/**
|
||||
* 删除流水线代码扫描
|
||||
* @param codeScanId 流水线代码扫描id
|
||||
*/
|
||||
void deleteCodeScan(String codeScanId);
|
||||
|
||||
/**
|
||||
* 更新代码扫描信息
|
||||
* @param taskCodeScan 信息
|
||||
*/
|
||||
void updateCodeScan(TaskCodeScan taskCodeScan);
|
||||
|
||||
|
||||
Boolean codeScanValid(String taskType,TaskCodeScan taskCodeScan);
|
||||
|
||||
|
||||
/**
|
||||
* 根据配置id查询任务
|
||||
* @param taskId 配置id
|
||||
* @return 任务
|
||||
*/
|
||||
TaskCodeScan findCodeScanByAuth(String taskId);
|
||||
|
||||
/**
|
||||
* 查询代码扫描信息
|
||||
* @param codeScanId id
|
||||
* @return 信息
|
||||
*/
|
||||
// @FindOne
|
||||
TaskCodeScan findOneCodeScan(String codeScanId);
|
||||
|
||||
/**
|
||||
* 查询所有流水线代码扫描
|
||||
* @return 流水线代码扫描列表
|
||||
*/
|
||||
// @FindAll
|
||||
List<TaskCodeScan> findAllCodeScan();
|
||||
|
||||
|
||||
// @FindList
|
||||
List<TaskCodeScan> findAllCodeScanList(List<String> idList);
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class MavenTest {
|
||||
|
||||
// id
|
||||
private String id;
|
||||
|
||||
// 流水线ID
|
||||
private String pipelineId;
|
||||
|
||||
// 创建时间
|
||||
private String createTime;
|
||||
|
||||
// 名称
|
||||
private String name;
|
||||
|
||||
// 包路径
|
||||
private String packagePath;
|
||||
|
||||
// 执行人
|
||||
private String userId;
|
||||
|
||||
// 全部测试用例
|
||||
private String allNumber;
|
||||
|
||||
// 失败的用例数
|
||||
private String failNumber;
|
||||
|
||||
// 错误的用例数
|
||||
private String errorNumber;
|
||||
|
||||
// 跳过的用例数
|
||||
private String skipNumber;
|
||||
|
||||
// 信息
|
||||
private String message;
|
||||
|
||||
// 总测试实例ID
|
||||
private String testId;
|
||||
|
||||
// 测试状态
|
||||
private String testState;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
//
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class MavenTestQuery {
|
||||
|
||||
// 流水线ID
|
||||
private String pipelineId;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String testId;
|
||||
|
||||
//@ApiProperty(name ="pageParam",desc = "分页参数")
|
||||
private PageParam pageParam= new PageParam();
|
||||
|
||||
//@ApiProperty(name ="orderParams",desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().desc("createTime").get();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import cd.casic.ci.commons.bean.process.definition.Pipeline;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
//@ApiModel
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class RelevanceTestOn {
|
||||
|
||||
|
||||
private String relevanceId;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "pipeline.id",target = "pipelineId")
|
||||
// })
|
||||
// @JoinQuery(key = "id")
|
||||
private Pipeline pipeline;
|
||||
|
||||
private String time;
|
||||
|
||||
private String authId;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String testonId;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Object object;
|
||||
|
||||
private String url;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class RelevanceTestOnQuery {
|
||||
|
||||
private String pipelineId;
|
||||
|
||||
//@ApiProperty(name ="pageParam",desc = "分页参数")
|
||||
private PageParam pageParam= new PageParam();
|
||||
|
||||
//@ApiProperty(name ="orderParams",desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().desc("createTime").get();
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 任务测试模型
|
||||
*/
|
||||
//@ApiModel
|
||||
//@Join
|
||||
//@Mapper
|
||||
@Data
|
||||
public class TaskTest {
|
||||
|
||||
//@ApiProperty(name = "taskId",desc = "id")
|
||||
private String taskId;
|
||||
|
||||
//测试内容
|
||||
//@ApiProperty(name="testOrder",desc="测试内容",required = true)
|
||||
private String testOrder;
|
||||
|
||||
//@ApiProperty(name="address",desc="测试地址",required = true)
|
||||
private String address;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "testSpace.id",target = "testSpace")
|
||||
// })
|
||||
// @JoinQuery(key = "testSpace")
|
||||
private TestOnRepository testSpace;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "testPlan.id",target = "testPlan")
|
||||
// })
|
||||
// @JoinQuery(key = "testPlan")
|
||||
private TestOnTestPlan testPlan;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "apiEnv.id",target = "apiEnv")
|
||||
// })
|
||||
// @JoinQuery(key = "apiEnv")
|
||||
private TestOnApiEnv apiEnv;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "appEnv.id",target = "appEnv")
|
||||
// })
|
||||
// @JoinQuery(key = "appEnv")
|
||||
private TestOnAppEnv appEnv;
|
||||
|
||||
// @Mappings({
|
||||
// @Mapping(source = "webEnv.id",target = "webEnv")
|
||||
// })
|
||||
// @JoinQuery(key = "webEnv")
|
||||
private TestOnWebEnv webEnv;
|
||||
|
||||
//@ApiProperty(name = "authId",desc="认证id")
|
||||
private String authId;
|
||||
|
||||
private Object auth;
|
||||
|
||||
//测试类型
|
||||
private String type;
|
||||
|
||||
//顺序
|
||||
private int sort;
|
||||
|
||||
private String instanceId;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestOnApiEnv {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class TestOnApiEnvQuery {
|
||||
|
||||
private String repositoryId;
|
||||
|
||||
// @ApiProperty(name = "orderParams", desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().asc("id").get();
|
||||
|
||||
// @ApiProperty(name = "pageParam", desc = "分页参数")
|
||||
private PageParam pageParam = new PageParam();
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestOnAppEnv {
|
||||
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class TestOnAppEnvQuery {
|
||||
|
||||
private String repositoryId;
|
||||
|
||||
// @ApiProperty(name = "orderParams", desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().asc("id").get();
|
||||
|
||||
// @ApiProperty(name = "pageParam", desc = "分页参数")
|
||||
private PageParam pageParam = new PageParam();
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
|
||||
public class TestOnPlanCaseInstance {
|
||||
|
||||
//@ApiProperty(name = "id", desc = "id")
|
||||
private String id;
|
||||
|
||||
//@ApiProperty(name = "testPlanInstanceId", desc = "所属测试计划实例")
|
||||
private String testPlanInstanceId;
|
||||
|
||||
//@ApiProperty(name = "caseInstanceId", desc = "用例实例id")
|
||||
private String caseInstanceId;
|
||||
|
||||
//@ApiProperty(name = "name", desc = "名称")
|
||||
private String name;
|
||||
|
||||
//@ApiProperty(name = "testType", desc = "测试类型")
|
||||
private String testType;
|
||||
|
||||
//@ApiProperty(name = "caseType", desc = "用例类型")
|
||||
private String caseType;
|
||||
|
||||
//@ApiProperty(name = "result", desc = "结果")
|
||||
private Integer result;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class TestOnPlanCaseInstanceBindQuery {
|
||||
|
||||
|
||||
// @ApiProperty(name = "caseInstanceId", desc = "历史id")
|
||||
private String caseInstanceId;
|
||||
|
||||
// @ApiProperty(name = "testPlanInstanceId", desc = "testPlanInstanceId")
|
||||
private String testPlanInstanceId;
|
||||
|
||||
|
||||
// @ApiProperty(name = "orderParams", desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().asc("id").get();
|
||||
|
||||
// @ApiProperty(name = "pageParam", desc = "分页参数")
|
||||
private PageParam pageParam = new PageParam();
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class TestOnPlanInstance {
|
||||
|
||||
//@ApiProperty(name = "id", desc = "id")
|
||||
private String id;
|
||||
|
||||
//@ApiProperty(name = "testPlanId", desc = "所属计划")
|
||||
private String testPlanId;
|
||||
|
||||
private TestOnTestPlan testPlan;
|
||||
|
||||
//@ApiProperty(name = "repositoryId", desc = "所属仓库")
|
||||
private String repositoryId;
|
||||
|
||||
//@ApiProperty(name = "executeNumber", desc = "执行次数")
|
||||
private Integer executeNumber;
|
||||
|
||||
//@ApiProperty(name = "result", desc = "结果")
|
||||
private Integer result;
|
||||
|
||||
//@ApiProperty(name = "total", desc = "测试总次数")
|
||||
private Integer total;
|
||||
|
||||
//@ApiProperty(name = "passNum", desc = "通过数")
|
||||
private Integer passNum;
|
||||
|
||||
//@ApiProperty(name = "failNum", desc = "错误数")
|
||||
private Integer failNum;
|
||||
|
||||
//@ApiProperty(name = "passRate", desc = "通过率")
|
||||
private String passRate;
|
||||
|
||||
//@ApiProperty(name = "errorRate", desc = "错误率")
|
||||
private String errorRate;
|
||||
|
||||
//@ApiProperty(name = "createTime", desc = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Timestamp createTime;
|
||||
|
||||
//@ApiProperty(name = "createUser", desc = "执行人")
|
||||
private String createUser;
|
||||
|
||||
private String testPlanName;
|
||||
|
||||
private String url;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class TestOnPlanQuery {
|
||||
|
||||
// @ApiProperty(name = "orderParams", desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().asc("id").get();
|
||||
|
||||
// @ApiProperty(name = "pageParam", desc = "分页参数")
|
||||
private PageParam pageParam = new PageParam();
|
||||
|
||||
// @ApiProperty(name = "repositoryId", desc = "空间id")
|
||||
private String repositoryId;
|
||||
|
||||
// @ApiProperty(name = "name", desc = "测试计划名字,模糊匹配")
|
||||
private String name;
|
||||
|
||||
// @ApiProperty(name = "state", desc = "测试计划名字,模糊匹配")
|
||||
private Integer state;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestOnPlanTestData {
|
||||
|
||||
|
||||
private String testPlanId;
|
||||
|
||||
private String repositoryId;
|
||||
|
||||
private String apiEnvId;
|
||||
|
||||
private String webEnv;
|
||||
|
||||
private String appEnv;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TestOnRelevance {
|
||||
|
||||
private String pipelineId;
|
||||
|
||||
private String instanceId;
|
||||
|
||||
private String authId;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestOnRepository {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestOnTestPlan {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestOnWebEnv {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String preUrl;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
import cd.casic.ci.commons.bean.order.Order;
|
||||
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class TestOnWebEnvQuery {
|
||||
|
||||
private String repositoryId;
|
||||
|
||||
// @ApiProperty(name = "orderParams", desc = "排序参数")
|
||||
private List<Order> orderParams = OrderBuilders.instance().asc("id").get();
|
||||
|
||||
// @ApiProperty(name = "pageParam", desc = "分页参数")
|
||||
private PageParam pageParam = new PageParam();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cd.casic.module.process.task.test.model;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestPlanExecResult {
|
||||
|
||||
//@ApiProperty(name = "status", desc = "状态类型:0:未开始,1:正在执行,2:结束")
|
||||
private Integer status;
|
||||
|
||||
//@ApiProperty(name = "testPlanInstance", desc = "测试实例")
|
||||
|
||||
private TestOnPlanInstance testPlanInstance;
|
||||
|
||||
// @ApiProperty(
|
||||
// name = "testPlanCaseInstanceList",
|
||||
// desc = "测试计划用例历史"
|
||||
// )
|
||||
// private List<TestPlanCaseInstanceBind> testPlanCaseInstanceList;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cd.casic.module.process.task.test.service;
|
||||
|
||||
|
||||
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.module.process.task.test.model.MavenTest;
|
||||
import cd.casic.module.process.task.test.model.MavenTestQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MavenTestService {
|
||||
|
||||
String creatMavenTest(MavenTest mavenTest) ;
|
||||
|
||||
void updateMavenTest(MavenTest mavenTest) ;
|
||||
|
||||
|
||||
void deleteMavenTest(String testId) ;
|
||||
|
||||
|
||||
MavenTest findOneMavenTest(String testId) ;
|
||||
|
||||
List<MavenTest> findAllMavenTest() ;
|
||||
|
||||
|
||||
List<MavenTest> findMavenTestList(MavenTestQuery testQuery);
|
||||
|
||||
|
||||
PageResult<MavenTest> findMavenTestPage(MavenTestQuery testQuery);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package cd.casic.module.process.task.test.service;
|
||||
|
||||
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.module.process.task.test.model.RelevanceTestOn;
|
||||
import cd.casic.module.process.task.test.model.RelevanceTestOnQuery;
|
||||
import cd.casic.module.process.task.test.model.TestOnRelevance;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//@JoinProvider(model = RelevanceTestOn.class)
|
||||
public interface RelevanceTestOnService {
|
||||
|
||||
|
||||
void createRelevance(TestOnRelevance testOnRelevance);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param relevanceTestOn 关联关系
|
||||
* @return 关联关系id
|
||||
*/
|
||||
String createRelevance(RelevanceTestOn relevanceTestOn);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param relevanceId 关联id
|
||||
*/
|
||||
void deleteRelevance(String relevanceId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据配置id删除任务
|
||||
* @param pipelineId 流水线id
|
||||
*/
|
||||
void deleteAllRelevance(String pipelineId);
|
||||
|
||||
/**
|
||||
* 获取流水线关联的testOn关系
|
||||
* @param pipelineId 流水线id
|
||||
* @return 关联关系
|
||||
*/
|
||||
List<RelevanceTestOn> findAllRelevance(String pipelineId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取流水线关联的testOn关系
|
||||
* @param relevanceTestOnQuery 条件
|
||||
* @return 关联关系
|
||||
*/
|
||||
PageResult<RelevanceTestOn> findAllRelevancePage(RelevanceTestOnQuery relevanceTestOnQuery);
|
||||
|
||||
|
||||
/**
|
||||
* 查询单个信息
|
||||
* @param relevanceId 关联id
|
||||
* @return 关联关系
|
||||
*/
|
||||
// @FindOne
|
||||
RelevanceTestOn findOneRelevance(String relevanceId);
|
||||
|
||||
/**
|
||||
* 查询所有信息
|
||||
* @return test信息集合
|
||||
*/
|
||||
// @FindAll
|
||||
List<RelevanceTestOn> findAllRelevance();
|
||||
|
||||
// @FindList
|
||||
List<RelevanceTestOn> findAllRelevanceList(List<String> idList);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package cd.casic.module.process.task.test.service;
|
||||
|
||||
|
||||
|
||||
import cd.casic.module.process.task.test.model.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TaskTestOnService {
|
||||
|
||||
/**
|
||||
* 根据名称查询仓库
|
||||
* @param authId 认证id
|
||||
* @param rpyId 仓库id
|
||||
* @return 仓库
|
||||
*/
|
||||
TestOnRepository findOneRepository(String authId, String rpyId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取测试计划
|
||||
* @param authId 认证id
|
||||
* @param planId 测试计划id
|
||||
* @return 测试计划
|
||||
*/
|
||||
TestOnTestPlan findOneTestPlan(String authId, String planId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取test仓库
|
||||
* @param authId 认证id
|
||||
* @return 仓库
|
||||
*/
|
||||
List<TestOnRepository> findAllRepository(String authId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取teston测试计划
|
||||
* @param authId 认证id
|
||||
* @param rpyId 仓库id
|
||||
* @return 测试计划
|
||||
*/
|
||||
List<TestOnTestPlan> findAllTestPlan(String authId, String rpyId);
|
||||
|
||||
/**
|
||||
* 获取测试计划环境
|
||||
* @param authId 认证id
|
||||
* @param rpyId 仓库id
|
||||
* @param env 环境
|
||||
* @return 环境信息
|
||||
*/
|
||||
List<Object> findAllEnv(String authId,String rpyId,String env);
|
||||
|
||||
/**
|
||||
* 获取测试集合执行需要的环境
|
||||
* @param authId teston环境地址
|
||||
* @param testPlanId 测试计划ID
|
||||
* @return 需要的环境
|
||||
*/
|
||||
List<String> findTestPlanEnv(String authId,String testPlanId);
|
||||
|
||||
/**
|
||||
* 获取api环境地址
|
||||
* @param authId teston环境地址
|
||||
* @param id id
|
||||
* @return api环境
|
||||
*/
|
||||
TestOnApiEnv findOneTestOnApiEnv(String authId, String id);
|
||||
|
||||
/**
|
||||
* 获取app环境地址
|
||||
* @param authId teston环境地址
|
||||
* @param id id
|
||||
* @return app环境
|
||||
*/
|
||||
TestOnAppEnv findOneTestOnAppEnv(String authId, String id);
|
||||
|
||||
/**
|
||||
* 获取web环境地址
|
||||
* @param authId teston环境地址
|
||||
* @param id id
|
||||
* @return web环境
|
||||
*/
|
||||
TestOnWebEnv findOneTestOnWebEnv(String authId, String id);
|
||||
|
||||
|
||||
/**
|
||||
* 执行测试计划
|
||||
* @param authId 认证id
|
||||
* @param testPlanTestData 执行信息
|
||||
*/
|
||||
String execTestPlan(String authId, TestOnPlanTestData testPlanTestData);
|
||||
|
||||
|
||||
/**
|
||||
* 获取测试结果详情
|
||||
* @param authId 认证id
|
||||
* @return 测试结果
|
||||
*/
|
||||
List<TestOnPlanCaseInstance> findTestPlanExecResult(String authId, String instanceId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取测试结果
|
||||
* @param authId 认证id
|
||||
* @return 测试结果
|
||||
*/
|
||||
TestPlanExecResult findPlanExecResult(String authId,String testPlanId);
|
||||
|
||||
/**
|
||||
* 查询测试计划的详情
|
||||
* @param authId 认证id
|
||||
* @param instanceId 实例id
|
||||
* @return 测试计划详情
|
||||
*/
|
||||
TestOnPlanInstance findAllTestPlanInstance(String authId, String instanceId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cd.casic.module.process.ws.config;
|
||||
|
||||
|
||||
import cd.casic.module.process.ws.server.SocketServerHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableWebSocket
|
||||
public class MatflowWebSocketConfig implements WebSocketConfigurer {
|
||||
|
||||
@Override
|
||||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||||
registry.addHandler(socketHandler(), "/arbess/handler")
|
||||
.addInterceptors()
|
||||
.setAllowedOrigins("*");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SocketServerHandler socketHandler() {
|
||||
return new SocketServerHandler();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletServerContainerFactoryBean createWebSocketContainer() {
|
||||
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
|
||||
container.setMaxTextMessageBufferSize(5120 * 5120); // 设置文本消息缓冲区大小
|
||||
container.setMaxBinaryMessageBufferSize(5120 * 5120); // 设置二进制消息缓冲区大小
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,152 @@
|
||||
package cd.casic.module.process.ws.server;
|
||||
|
||||
import cd.casic.ci.commons.bean.exception.SystemException;
|
||||
import cd.casic.ci.commons.bean.utils.PipelineUtil;
|
||||
import cd.casic.ci.commons.bean.work.agent.AgentMessage;
|
||||
import cd.casic.ci.commons.bean.work.agent.model.Agent;
|
||||
import cd.casic.module.process.support.agent.service.AgentService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.socket.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@Service
|
||||
public class SocketServerHandler implements WebSocketHandler {
|
||||
@Resource
|
||||
WebSocketMessageService webSocketMessageService;
|
||||
|
||||
@Resource
|
||||
AgentService agentService;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final List<AgentMessage> dataList = new CopyOnWriteArrayList<>();
|
||||
|
||||
// 线程安全的集合,用于存储客户端会话
|
||||
public static final Map<String, WebSocketSession> sessionMap = new HashMap<>();
|
||||
|
||||
public static SocketServerHandler instance(){
|
||||
return new SocketServerHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
// 连接建立时的处理逻辑
|
||||
Agent agent = connentAgent(String.valueOf(session.getUri()));
|
||||
sessionMap.put(agent.getAddress(),session);
|
||||
agentService.initAgent(agent);
|
||||
logger.info("客户端建立连接,{}", agent.getAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
||||
// 接收到消息时的处理逻辑
|
||||
BinaryMessage binaryMessage = (BinaryMessage) message;
|
||||
ByteBuffer payload = binaryMessage.getPayload();
|
||||
String receivedString = new String(payload.array(), StandardCharsets.UTF_8);
|
||||
AgentMessage agentMessage = JSONObject.parseObject(receivedString, AgentMessage.class);
|
||||
logger.warn("接受客户端消息,消息类型:{}", agentMessage.getType());
|
||||
|
||||
dataList.add(agentMessage);
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(fixedRate = 800)
|
||||
protected void syncMessage(){
|
||||
if (dataList.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
||||
int processedCount = 0; // 计数器
|
||||
for (AgentMessage message : dataList) {
|
||||
if (processedCount >= 4) { // 限制每次处理的数量为6
|
||||
break;
|
||||
}
|
||||
|
||||
// 执行处理逻辑
|
||||
webSocketMessageService.distributeMessage(message);
|
||||
processedCount++;
|
||||
|
||||
// 处理完成后删除内存中的数据
|
||||
dataList.remove(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param id 消息ID
|
||||
* @param agentMessage 消息内容
|
||||
*/
|
||||
public void sendHandleMessage(String id, AgentMessage agentMessage){
|
||||
WebSocketSession session = sessionMap.get(id);
|
||||
if (Objects.isNull(session) || !session.isOpen()) {
|
||||
throw new SystemException("客户端推送消息失败,无法获取客户端连接,客户端信息:"+id);
|
||||
}
|
||||
// 接收到消息时的处理逻辑
|
||||
String jsonString = JSONObject.toJSONString(agentMessage);
|
||||
logger.warn("向客户端推送消息:{}",agentMessage.getType());
|
||||
try {
|
||||
session.sendMessage(new TextMessage(jsonString));
|
||||
} catch (IOException e) {
|
||||
throw new SystemException("客户端推送消息失败,错误信息:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
|
||||
// 发生传输错误时的处理逻辑
|
||||
logger.error("连接过程异常,异常信息:{}", exception.getMessage());
|
||||
Agent agent = connentAgent(Objects.requireNonNull(session.getUri()).toString());
|
||||
// connetMap.remove(agent.getAddress());
|
||||
sessionMap.remove(agent.getAddress(),session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
||||
// 连接关闭时的处理逻辑
|
||||
Agent agent = connentAgent(Objects.requireNonNull(session.getUri()).toString());
|
||||
String address = agent.getAddress();
|
||||
logger.warn("客户端关闭连接,id:{},原因:{}", address,closeStatus.getReason());
|
||||
sessionMap.remove(address,session);
|
||||
// agentService.deleteAgent(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPartialMessages() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析连接信息
|
||||
* @param uri 连接地址
|
||||
* @return 连接信息
|
||||
*/
|
||||
public Agent connentAgent(String uri){
|
||||
String[] split = Objects.requireNonNull(uri).split("\\?");
|
||||
String[] split1 = split[1].split("&");
|
||||
Agent agent = new Agent();
|
||||
agent.setName(split1[0]);
|
||||
agent.setTenantId(split1[1]);
|
||||
agent.setIp(split1[2]);
|
||||
agent.setCreateTime(PipelineUtil.date(1));
|
||||
agent.setAddress(split1[0]+"-"+split1[1]);
|
||||
return agent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cd.casic.module.process.ws.server;
|
||||
|
||||
import cd.casic.ci.commons.bean.work.agent.AgentMessage;
|
||||
|
||||
|
||||
public interface WebSocketMessageService {
|
||||
|
||||
|
||||
/**
|
||||
* 分发处理消息
|
||||
* @param agentMessage 消息内容
|
||||
*/
|
||||
String distributeMessage(AgentMessage agentMessage);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,364 @@
|
||||
package cd.casic.module.process.ws.server.impl;
|
||||
|
||||
import cd.casic.ci.commons.bean.engine.job.TaskInstance;
|
||||
import cd.casic.ci.commons.bean.engine.postprocess.PostprocessInstance;
|
||||
import cd.casic.ci.commons.bean.process.definition.Pipeline;
|
||||
import cd.casic.ci.commons.bean.process.instance.PipelineInstance;
|
||||
import cd.casic.ci.commons.bean.process.stage.StageInstance;
|
||||
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
||||
import cd.casic.ci.commons.bean.utils.PipelineFileUtil;
|
||||
import cd.casic.ci.commons.bean.utils.PipelineUtil;
|
||||
import cd.casic.ci.commons.bean.work.agent.AgentMessage;
|
||||
import cd.casic.module.process.engine.task.TasksInstanceService;
|
||||
import cd.casic.module.process.home.service.PipelineHomeService;
|
||||
import cd.casic.module.process.pipeline.definition.PipelineService;
|
||||
import cd.casic.module.process.pipeline.execute.service.impl.PipelineExecServiceImpl;
|
||||
import cd.casic.module.process.process.instance.PipelineInstanceService;
|
||||
import cd.casic.module.process.stages.service.StageInstanceServer;
|
||||
import cd.casic.module.process.support.postprocess.service.PostprocessInstanceService;
|
||||
import cd.casic.module.process.support.util.PipelineUtilService;
|
||||
import cd.casic.module.process.support.util.util.PipelineFinal;
|
||||
import cd.casic.module.process.task.code.service.SpotbugsScanService;
|
||||
import cd.casic.module.process.task.test.model.MavenTest;
|
||||
import cd.casic.module.process.task.test.model.TestOnRelevance;
|
||||
import cd.casic.module.process.task.test.service.MavenTestService;
|
||||
import cd.casic.module.process.task.test.service.RelevanceTestOnService;
|
||||
import cd.casic.module.process.ws.server.WebSocketMessageService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class WebSocketMessageServiceImpl implements WebSocketMessageService {
|
||||
|
||||
@Autowired
|
||||
PipelineService pipelineService;
|
||||
|
||||
@Autowired
|
||||
PipelineInstanceService pipelineInstanceService;
|
||||
|
||||
@Autowired
|
||||
StageInstanceServer stageInstanceServer;
|
||||
|
||||
@Autowired
|
||||
TasksInstanceService tasksInstanceService;
|
||||
|
||||
@Autowired
|
||||
MavenTestService mavenTestService;
|
||||
|
||||
@Autowired
|
||||
SpotbugsScanService spotbugsScanService;
|
||||
|
||||
@Autowired
|
||||
RelevanceTestOnService relevanceTestOnService;
|
||||
|
||||
@Autowired
|
||||
PipelineUtilService utilService;
|
||||
|
||||
@Autowired
|
||||
PipelineHomeService homeService;
|
||||
|
||||
@Autowired
|
||||
PostprocessInstanceService postprocessInstanceService;
|
||||
|
||||
@Autowired
|
||||
TaskDeployInstanceServiceImpl deployInstanceService;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public String distributeMessage(AgentMessage agentMessage){
|
||||
String type = agentMessage.getType();
|
||||
Object message = agentMessage.getMessage();
|
||||
if (type.contains("deploy_instance_log")){
|
||||
messageTaskDeployInstanceLogHandle( message);
|
||||
}else if (type.contains("deploy_end_instance_log")){
|
||||
messageTaskDeployInstanceLogHandle(message);
|
||||
}else if (type.contains("log")){
|
||||
logMessageHandle(message);
|
||||
}else if (type.contains("pipeline_run")){
|
||||
pipelineMessageHandle( message);
|
||||
}else if (type.contains("stage_run")){
|
||||
stageMessageHandle(message);
|
||||
} else if (type.contains("post_run")){
|
||||
postMessageHandle(message);
|
||||
} else if (type.contains("task_run")){
|
||||
taskMessageHandle(message);
|
||||
}else if (type.contains("maven_unittest")){
|
||||
mavenTestTaskMessageHandle(message);
|
||||
}else if (type.contains("task_codescan")){
|
||||
codeScanTaskMessageHandle(message);
|
||||
} else if (type.contains("test_teston_exec")){
|
||||
testOnTaskMessageHandle(message);
|
||||
}else if (type.contains("send_message")){
|
||||
messageTaskMessageHandle(message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 流水线消息处理
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void pipelineMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
PipelineInstance sourceInstance = JSONObject.parseObject(jsonString,PipelineInstance.class);
|
||||
// 更新实例状态
|
||||
String instanceId = sourceInstance.getInstanceId();
|
||||
String runStatus = sourceInstance.getRunStatus();
|
||||
PipelineInstance instance = pipelineInstanceService.findOneInstance(instanceId);
|
||||
int runtime = pipelineInstanceService.findInstanceRuntime(instanceId);
|
||||
instance.setRunTime(runtime+1);
|
||||
instance.setRunStatus(runStatus);
|
||||
pipelineInstanceService.updateInstance(instance);
|
||||
|
||||
// 设置流水线为未运行
|
||||
String pipelineId = instance.getPipeline().getId();
|
||||
Pipeline pipeline = pipelineService.findPipelineById(pipelineId);
|
||||
pipeline.setState(1);
|
||||
pipelineService.updatePipeline(pipeline);
|
||||
PipelineExecServiceImpl.pipelineIdOrInstanceId.remove(pipelineId);
|
||||
|
||||
sendPipelineRunMessage(pipeline,instanceId,runStatus);
|
||||
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
public void sendPipelineRunMessage(Pipeline pipeline,String instanceId,String state){
|
||||
Map<String,Object> map = homeService.initMap(pipeline);
|
||||
map.put("instanceId",instanceId);
|
||||
map.put("link", PipelineFinal.RUN_LINK);
|
||||
PipelineInstance instance = pipelineInstanceService.findOneInstance(instanceId);
|
||||
|
||||
switch (state){
|
||||
case PipelineFinal.RUN_SUCCESS ->{
|
||||
map.put("message","运行成功");
|
||||
map.put("execStatus","运行成功");
|
||||
map.put("colour","info");
|
||||
}
|
||||
case PipelineFinal.RUN_ERROR ->{
|
||||
map.put("colour","warning");
|
||||
map.put("message","运行失败");
|
||||
map.put("execStatus","运行失败");
|
||||
}
|
||||
case PipelineFinal.RUN_HALT ->{
|
||||
map.put("colour","warning");
|
||||
map.put("message","停止运程");
|
||||
map.put("execStatus","停止运程");
|
||||
}
|
||||
default -> {
|
||||
map.put("colour","info");
|
||||
map.put("message","运行成功");
|
||||
map.put("execStatus","运行成功");
|
||||
}
|
||||
}
|
||||
|
||||
String time = PipelineUtil.formatDateTime(instance.getRunTime());
|
||||
map.put("execTime",time);
|
||||
homeService.log(PipelineFinal.LOG_TYPE_RUN, map);
|
||||
map.put("dmMessage",true);
|
||||
homeService.settingMessage(PipelineFinal.MES_RUN, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 阶段消息处理
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void stageMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
StageInstance sourceStageInstance = JSONObject.parseObject(jsonString,StageInstance.class);
|
||||
StageInstance stageInstance = stageInstanceServer.findOneStageInstance(sourceStageInstance.getId());
|
||||
stageInstance.setStageTime(sourceStageInstance.getStageTime());
|
||||
stageInstance.setStageState(sourceStageInstance.getStageState());
|
||||
stageInstanceServer.updateStageInstance(stageInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务消息处理
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void taskMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
|
||||
TaskInstance sourceTaskInstance = JSONObject.parseObject(jsonString,TaskInstance.class);
|
||||
String id = sourceTaskInstance.getId();
|
||||
TaskInstance taskInstance = tasksInstanceService.findOneTaskInstance(id);
|
||||
|
||||
TaskInstance mapTaskInstance = TasksInstanceServiceImpl.taskInstanceMap.get(id);
|
||||
if (!Objects.isNull(mapTaskInstance)){
|
||||
String runLog = mapTaskInstance.getRunLog();
|
||||
taskInstance.setRunTime(sourceTaskInstance.getRunTime());
|
||||
taskInstance.setRunLog(runLog);
|
||||
taskInstance.setRunState(sourceTaskInstance.getRunState());
|
||||
String logAddress = taskInstance.getLogAddress();
|
||||
PipelineFileUtil.logWriteFile(runLog,logAddress);
|
||||
}
|
||||
tasksInstanceService.updateTaskInstance(taskInstance);
|
||||
TasksInstanceServiceImpl.taskInstanceMap.remove(taskInstance.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志消息处理
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void logMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
TaskInstance sourceTaskInstance = JSONObject.parseObject(jsonString,TaskInstance.class);
|
||||
String id = sourceTaskInstance.getId();
|
||||
TaskInstance taskInstance = TasksInstanceServiceImpl.taskInstanceMap.get(id);
|
||||
if (!Objects.isNull(taskInstance)){
|
||||
if (!StringUtils.isEmpty(sourceTaskInstance.getRunLog())){
|
||||
sourceTaskInstance.setRunLog(taskInstance.getRunLog()+"\n"+sourceTaskInstance.getRunLog());
|
||||
}else {
|
||||
sourceTaskInstance.setRunLog(taskInstance.getRunLog());
|
||||
}
|
||||
}
|
||||
updateTaskInstance(sourceTaskInstance);
|
||||
TasksInstanceServiceImpl.taskInstanceMap.put(sourceTaskInstance.getId(), sourceTaskInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志过长更新
|
||||
* @param taskInstance 日志信息
|
||||
*/
|
||||
private void updateTaskInstance(TaskInstance taskInstance){
|
||||
if (Objects.isNull(taskInstance)){
|
||||
return;
|
||||
}
|
||||
|
||||
String id = taskInstance.getId();
|
||||
TaskInstance oneTaskInstance = tasksInstanceService.findOneTaskInstance(id);
|
||||
if (Objects.isNull(oneTaskInstance)){
|
||||
return;
|
||||
}
|
||||
|
||||
String runLog = taskInstance.getRunLog();
|
||||
if (StringUtils.isEmpty(runLog)){
|
||||
return;
|
||||
}
|
||||
|
||||
String[] split = runLog.split("\n");
|
||||
if (taskInstance.getTaskSort() < 2){
|
||||
if (split.length < 3){
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
if (split.length < 30){
|
||||
return;
|
||||
}
|
||||
}
|
||||
String logAddress = oneTaskInstance.getLogAddress();
|
||||
logger.info("日志过长,写入文件:{}",logAddress);
|
||||
|
||||
PipelineFileUtil.logWriteFile(runLog,logAddress);
|
||||
|
||||
taskInstance.setRunLog("");
|
||||
}
|
||||
|
||||
/**
|
||||
* 单元测试结果
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void mavenTestTaskMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
MavenTest mavenTest = JSONObject.parseObject(jsonString, MavenTest.class);
|
||||
String id = mavenTest.getId();
|
||||
MavenTest oneMavenTest = mavenTestService.findOneMavenTest(id);
|
||||
if (Objects.isNull(oneMavenTest)){
|
||||
mavenTestService.creatMavenTest(mavenTest);
|
||||
}else {
|
||||
mavenTestService.updateMavenTest(mavenTest);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息结果
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void messageTaskMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
TaskMessage taskMessage = JSONObject.parseObject(jsonString, TaskMessage.class);
|
||||
Pipeline pipeline = pipelineService.findOnePipeline(taskMessage.getPipelineId());
|
||||
Map<String, Object> stringObjectMap = homeService.initMap(pipeline);
|
||||
stringObjectMap.putAll(taskMessage.getMap());
|
||||
homeService.message(stringObjectMap,taskMessage.getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息结果
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void messageTaskDeployInstanceLogHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
TaskDeployInstance deployInstance = JSONObject.parseObject(jsonString, TaskDeployInstance.class);
|
||||
TaskDeployInstance sourceDeployInstance = deployInstanceService.findDeployInstance(deployInstance.getId());
|
||||
sourceDeployInstance.setRunStatus(deployInstance.getRunStatus());
|
||||
sourceDeployInstance.setRunTime(deployInstance.getRunTime());
|
||||
deployInstanceService.updateDeployInstance(sourceDeployInstance);
|
||||
}
|
||||
|
||||
private void messageTaskDeployInstanceLogEndHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
TaskDeployInstance deployInstance = JSONObject.parseObject(jsonString, TaskDeployInstance.class);
|
||||
TaskDeployInstance sourceDeployInstance = deployInstanceService.findDeployInstance(deployInstance.getId());
|
||||
sourceDeployInstance.setRunStatus(deployInstance.getRunStatus());
|
||||
deployInstanceService.updateDeployInstance(sourceDeployInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代码扫描结果
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void codeScanTaskMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
SpotbugsBugSummary spotbugsBugSummary = JSONObject.parseObject(jsonString, SpotbugsBugSummary.class);
|
||||
String xmlFileContent = spotbugsBugSummary.getXmlFileContent();
|
||||
String pipelineId = spotbugsBugSummary.getPipelineId();
|
||||
|
||||
String logAddress = utilService.findPipelineDefaultAddress(pipelineId, 2)+"/spotbugs/spotbugs-"+new Date().getTime()+".xml";
|
||||
|
||||
PipelineFileUtil.createFile(logAddress);
|
||||
PipelineFileUtil.logWriteFile(xmlFileContent,logAddress);
|
||||
logger.info("服务端报保存代码扫描文件:{}", logAddress);
|
||||
spotbugsBugSummary.setXmlPath(logAddress);
|
||||
spotbugsScanService.creatSpotbugs(spotbugsBugSummary);
|
||||
}
|
||||
|
||||
/**
|
||||
* testOn自动化测试
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void testOnTaskMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
TestOnRelevance testOnRelevance = JSONObject.parseObject(jsonString, TestOnRelevance.class);
|
||||
relevanceTestOnService.createRelevance(testOnRelevance);
|
||||
}
|
||||
|
||||
/**
|
||||
* testOn自动化测试
|
||||
* @param message 消息内容
|
||||
*/
|
||||
private void postMessageHandle(Object message){
|
||||
String jsonString = JSONObject.toJSONString(message);
|
||||
PostprocessInstance postprocessInstance = JSONObject.parseObject(jsonString, PostprocessInstance.class);
|
||||
String instanceId = postprocessInstance.getInstanceId();
|
||||
|
||||
List<PostprocessInstance> postInstanceList = postprocessInstanceService.findPipelinePostInstance(instanceId);
|
||||
if (postInstanceList.isEmpty()){
|
||||
return;
|
||||
}
|
||||
PostprocessInstance postInstance = postInstanceList.get(0);
|
||||
postInstance.setPostState(postprocessInstance.getPostState());
|
||||
postprocessInstanceService.updatePostInstance(postInstance);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user