service(添加ws依赖)
迁移
This commit is contained in:
parent
07654e2865
commit
254a2ded30
@ -1,5 +1,6 @@
|
|||||||
package cd.casic.ci.commons.bean.engine.job;
|
package cd.casic.ci.commons.bean.engine.job;
|
||||||
|
|
||||||
|
|
||||||
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@ -61,4 +62,6 @@ public class TaskInstance {
|
|||||||
|
|
||||||
// 部署实例日志
|
// 部署实例日志
|
||||||
private List<TaskDeployInstance> deployInstanceList;
|
private List<TaskDeployInstance> deployInstanceList;
|
||||||
|
// 执行顺序
|
||||||
|
private int taskSort ;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package cd.casic.module.process.engine.task.dao;
|
package cd.casic.module.process.engine.task.dao;
|
||||||
|
|
||||||
|
import cd.casic.ci.commons.bean.engine.job.TaskInstanceQuery;
|
||||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cd.casic.module.process.engine.task.dataobject.TaskInstanceDo;
|
import cd.casic.module.process.engine.task.dataobject.TaskInstanceDo;
|
||||||
|
import cd.casic.module.process.task.task.entity.TaskInstanceEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author by mianbin
|
* @author by mianbin
|
||||||
* @Classname TaskInstanceDao
|
* @Classname TaskInstanceDao
|
||||||
@ -12,4 +16,46 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TaskInstanceDao extends BaseMapperX<TaskInstanceDo> {
|
public interface TaskInstanceDao extends BaseMapperX<TaskInstanceDo> {
|
||||||
|
/**
|
||||||
|
* 创建流水线日志
|
||||||
|
* @param taskInstanceEntity 流水线历史日志
|
||||||
|
* @return 流水线日志id
|
||||||
|
*/
|
||||||
|
public String createInstance(TaskInstanceEntity taskInstanceEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除流水线日志
|
||||||
|
* @param id 流水线日志id
|
||||||
|
*/
|
||||||
|
public void deleteInstance(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新流水线日志
|
||||||
|
* @param taskInstanceEntity 更新后流水线日志信息
|
||||||
|
*/
|
||||||
|
public void updateInstance(TaskInstanceEntity taskInstanceEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询流水线日志
|
||||||
|
* @param id 查询id
|
||||||
|
* @return 流水线日志信息
|
||||||
|
*/
|
||||||
|
public TaskInstanceEntity findOne(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有流水线日志
|
||||||
|
* @return 流水线日志列表
|
||||||
|
*/
|
||||||
|
public List<TaskInstanceEntity> findAllInstance();
|
||||||
|
|
||||||
|
public List<TaskInstanceEntity> findStageInstance(String stageId);
|
||||||
|
|
||||||
|
public List<TaskInstanceEntity> findPipelineInstance(String instanceId);
|
||||||
|
public List<TaskInstanceEntity> findTaskInstanceList(TaskInstanceQuery query);
|
||||||
|
|
||||||
|
|
||||||
|
public List<TaskInstanceEntity> findPostInstance(String postprocessId);
|
||||||
|
|
||||||
|
|
||||||
|
public List<TaskInstanceEntity> findAllInstanceList(List<String> idList);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package cd.casic.module.process.task.build.model;
|
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;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package cd.casic.module.process.task.codescan.model;
|
package cd.casic.module.process.task.codescan.model;
|
||||||
|
|
||||||
import io.tiklab.core.order.Order;
|
|
||||||
import io.tiklab.core.order.OrderBuilders;
|
import cd.casic.ci.commons.bean.order.Order;
|
||||||
import io.tiklab.core.page.Page;
|
import cd.casic.ci.commons.bean.order.OrderBuilders;
|
||||||
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -14,34 +15,9 @@ public class SpotbugsBugQuery {
|
|||||||
|
|
||||||
private String pipelineId;
|
private String pipelineId;
|
||||||
|
|
||||||
private Page pageParam= new Page();
|
private PageParam pageParam= new PageParam();
|
||||||
|
|
||||||
private List<Order> orderParams = OrderBuilders.instance().desc("scanTime").get();
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,15 @@ package cd.casic.module.process.task.codescan.model;
|
|||||||
|
|
||||||
import io.tiklab.toolkit.beans.annotation.Mapper;
|
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||||
import io.tiklab.toolkit.join.annotation.Join;
|
import io.tiklab.toolkit.join.annotation.Join;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Spotbugs代码扫描信息
|
* @author Spotbugs代码扫描信息
|
||||||
*/
|
*/
|
||||||
@Join
|
//@Join
|
||||||
@Mapper(targetName = "io.tiklab.arbess.task.codescan.entity.SpotbugsScanEntity")
|
//@Mapper(targetName = "io.tiklab.arbess.task.codescan.entity.SpotbugsScanEntity")
|
||||||
// @Mapper
|
// @Mapper
|
||||||
|
@Data
|
||||||
public class SpotbugsBugSummary {
|
public class SpotbugsBugSummary {
|
||||||
|
|
||||||
// id
|
// id
|
||||||
@ -50,135 +52,4 @@ public class SpotbugsBugSummary {
|
|||||||
// xml文件内容
|
// xml文件内容
|
||||||
private String xmlFileContent;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package cd.casic.module.process.task.codescan.model;
|
package cd.casic.module.process.task.codescan.model;
|
||||||
|
|
||||||
import io.tiklab.toolkit.beans.annotation.Mapper;
|
import lombok.Data;
|
||||||
import io.tiklab.toolkit.join.annotation.Join;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务代码扫描模型
|
* 任务代码扫描模型
|
||||||
*/
|
*/
|
||||||
//@ApiModel
|
//@ApiModel
|
||||||
@Join
|
//@Join
|
||||||
@Mapper
|
//@Mapper
|
||||||
|
@Data
|
||||||
public class TaskCodeScan {
|
public class TaskCodeScan {
|
||||||
|
|
||||||
//@ApiProperty(name = "taskId",desc = "id")
|
//@ApiProperty(name = "taskId",desc = "id")
|
||||||
|
@ -0,0 +1,238 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.model;
|
||||||
|
|
||||||
|
import io.tiklab.arbess.setting.model.HostGroup;
|
||||||
|
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||||
|
import io.tiklab.toolkit.join.annotation.Join;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务部署模型
|
||||||
|
* @author zcamy
|
||||||
|
*/
|
||||||
|
//@ApiModel
|
||||||
|
@Join
|
||||||
|
@Mapper
|
||||||
|
public class TaskDeploy {
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskId",desc = "id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "authType",desc = "部署方式,自定义部署,结构化部署" )
|
||||||
|
private int authType;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "localAddress" , desc = "文件地址")
|
||||||
|
private String localAddress;
|
||||||
|
|
||||||
|
//@ApiProperty(name="deployAddress",desc="部署地址")
|
||||||
|
private String deployAddress;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "authId" , desc = "认证id")
|
||||||
|
private String authId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "deployOrder",desc = "部署命令" )
|
||||||
|
private String deployOrder;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "startAddress",desc = "启动文件地址" )
|
||||||
|
private String startAddress;
|
||||||
|
|
||||||
|
//@ApiProperty(name="startOrder",desc="启动命令")
|
||||||
|
private String startOrder;
|
||||||
|
|
||||||
|
//@ApiProperty(name="rule",desc="规则")
|
||||||
|
private String rule;
|
||||||
|
|
||||||
|
//@ApiProperty(name="dockerImage",desc="规则")
|
||||||
|
private String dockerImage;
|
||||||
|
|
||||||
|
// 主机类型 host--主机 hostGroup--主机组
|
||||||
|
private String hostType;
|
||||||
|
|
||||||
|
//授权信息
|
||||||
|
private Object auth;
|
||||||
|
|
||||||
|
private int sort;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
// 命名空间
|
||||||
|
private String k8sNamespace;
|
||||||
|
|
||||||
|
// 配置文件
|
||||||
|
private String k8sJson;
|
||||||
|
|
||||||
|
// 策略类型
|
||||||
|
private String strategyType;
|
||||||
|
|
||||||
|
// 策略数量
|
||||||
|
private Integer strategyNumber;
|
||||||
|
|
||||||
|
private String instanceId;
|
||||||
|
|
||||||
|
//
|
||||||
|
private List<HostGroup> hostGroupList;
|
||||||
|
|
||||||
|
public List<HostGroup> getHostGroupList() {
|
||||||
|
return hostGroupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostGroupList(List<HostGroup> hostGroupList) {
|
||||||
|
this.hostGroupList = hostGroupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstanceId() {
|
||||||
|
return instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstanceId(String instanceId) {
|
||||||
|
this.instanceId = instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrategyType() {
|
||||||
|
return strategyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStrategyType(String strategyType) {
|
||||||
|
this.strategyType = strategyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStrategyNumber() {
|
||||||
|
return strategyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStrategyNumber(Integer strategyNumber) {
|
||||||
|
this.strategyNumber = strategyNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getK8sNamespace() {
|
||||||
|
return k8sNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setK8sNamespace(String k8sNamespace) {
|
||||||
|
this.k8sNamespace = k8sNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getK8sJson() {
|
||||||
|
return k8sJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setK8sJson(String k8sJson) {
|
||||||
|
this.k8sJson = k8sJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHostType() {
|
||||||
|
return hostType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDeploy setHostType(String hostType) {
|
||||||
|
this.hostType = hostType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDockerImage() {
|
||||||
|
return dockerImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDeploy setDockerImage(String dockerImage) {
|
||||||
|
this.dockerImage = dockerImage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRule() {
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDeploy setRule(String rule) {
|
||||||
|
this.rule = rule;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(String taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAuthType() {
|
||||||
|
return authType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthType(int authType) {
|
||||||
|
this.authType = authType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalAddress() {
|
||||||
|
return localAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocalAddress(String localAddress) {
|
||||||
|
this.localAddress = localAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeployAddress() {
|
||||||
|
return deployAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeployAddress(String deployAddress) {
|
||||||
|
this.deployAddress = deployAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthId() {
|
||||||
|
return authId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthId(String authId) {
|
||||||
|
this.authId = authId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeployOrder() {
|
||||||
|
return deployOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeployOrder(String deployOrder) {
|
||||||
|
this.deployOrder = deployOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartAddress() {
|
||||||
|
return startAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartAddress(String startAddress) {
|
||||||
|
this.startAddress = startAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStartOrder() {
|
||||||
|
return startOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartOrder(String startOrder) {
|
||||||
|
this.startOrder = startOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuth(Object auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.model;
|
||||||
|
|
||||||
|
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public class TaskDeployInstance {
|
||||||
|
|
||||||
|
// id
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
// 实例ID
|
||||||
|
private String taskInstanceId;
|
||||||
|
|
||||||
|
// 名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
// 时间
|
||||||
|
private String runTime;
|
||||||
|
|
||||||
|
// 状态
|
||||||
|
private String runStatus;
|
||||||
|
|
||||||
|
// 运行日志
|
||||||
|
private String runLog;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
public Integer getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(Integer sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDeployInstance() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskDeployInstance(String id, String taskInstanceId) {
|
||||||
|
this.id = id;
|
||||||
|
this.taskInstanceId = taskInstanceId;
|
||||||
|
this.runStatus = "wait";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskInstanceId() {
|
||||||
|
return taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskInstanceId(String taskInstanceId) {
|
||||||
|
this.taskInstanceId = taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRunTime() {
|
||||||
|
return runTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunTime(String runTime) {
|
||||||
|
this.runTime = runTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRunStatus() {
|
||||||
|
return runStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunStatus(String runStatus) {
|
||||||
|
this.runStatus = runStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRunLog() {
|
||||||
|
return runLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunLog(String runLog) {
|
||||||
|
this.runLog = runLog;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.model;
|
||||||
|
|
||||||
|
|
||||||
|
public class TaskDeployInstanceQuery {
|
||||||
|
|
||||||
|
// 实例ID
|
||||||
|
private String taskInstanceId;
|
||||||
|
|
||||||
|
|
||||||
|
public String getTaskInstanceId() {
|
||||||
|
return taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskInstanceId(String taskInstanceId) {
|
||||||
|
this.taskInstanceId = taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.model;
|
||||||
|
|
||||||
|
import io.tiklab.arbess.setting.model.AuthHost;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TaskDeployStrategy {
|
||||||
|
|
||||||
|
private String taskInstanceId;
|
||||||
|
|
||||||
|
private String strategyInstanceId;
|
||||||
|
|
||||||
|
private List<AuthHost> authHostList;
|
||||||
|
|
||||||
|
|
||||||
|
public String getTaskInstanceId() {
|
||||||
|
return taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskInstanceId(String taskInstanceId) {
|
||||||
|
this.taskInstanceId = taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStrategyInstanceId() {
|
||||||
|
return strategyInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStrategyInstanceId(String strategyInstanceId) {
|
||||||
|
this.strategyInstanceId = strategyInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AuthHost> getAuthHostList() {
|
||||||
|
return authHostList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthHostList(List<AuthHost> authHostList) {
|
||||||
|
this.authHostList = authHostList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.service;
|
||||||
|
|
||||||
|
import io.tiklab.arbess.task.task.model.Tasks;
|
||||||
|
import io.tiklab.core.exception.ApplicationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署执行服务接口
|
||||||
|
*/
|
||||||
|
public interface TaskDeployExecService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署
|
||||||
|
* @param pipelineId 流水线id
|
||||||
|
* @param task 任务信息
|
||||||
|
* @param taskType 任务类型
|
||||||
|
* @return 执行状态 true:成功 false:失败
|
||||||
|
* @throws ApplicationException 运行失败
|
||||||
|
*/
|
||||||
|
boolean deploy(String pipelineId, Tasks task , String taskType);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
||||||
|
import cd.casic.module.process.task.deploy.model.TaskDeployInstanceQuery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface TaskDeployInstanceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建部署实例
|
||||||
|
* @param deployInstance deployInstance
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
|
String createDeployInstance(TaskDeployInstance deployInstance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新部署实例
|
||||||
|
* @param deployInstance deployInstance
|
||||||
|
*/
|
||||||
|
void updateDeployInstance(TaskDeployInstance deployInstance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除部署实例
|
||||||
|
* @param id id
|
||||||
|
*/
|
||||||
|
void deleteDeployInstance(String id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找部署实例
|
||||||
|
* @param id id
|
||||||
|
* @return deployInstance
|
||||||
|
*/
|
||||||
|
TaskDeployInstance findDeployInstance(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找部署实例
|
||||||
|
* @param deployInstanceQuery deployInstanceQuery
|
||||||
|
* @return deployInstance
|
||||||
|
*/
|
||||||
|
List<TaskDeployInstance> findAllDeployInstanceList(TaskDeployInstanceQuery deployInstanceQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找部署实例
|
||||||
|
* @return deployInstance
|
||||||
|
*/
|
||||||
|
List<TaskDeployInstance> findAllDeployInstanceList();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package cd.casic.module.process.task.deploy.service;
|
||||||
|
|
||||||
|
|
||||||
|
import io.tiklab.arbess.task.deploy.model.TaskDeploy;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindAll;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindList;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindOne;
|
||||||
|
import io.tiklab.toolkit.join.annotation.JoinProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署服务接口
|
||||||
|
*/
|
||||||
|
@JoinProvider(model = TaskDeploy.class)
|
||||||
|
public interface TaskDeployService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
* @param taskDeploy deploy信息
|
||||||
|
* @return deployId
|
||||||
|
*/
|
||||||
|
String createDeploy(TaskDeploy taskDeploy) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param deployId deployId
|
||||||
|
*/
|
||||||
|
void deleteDeploy(String deployId) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试是否有效
|
||||||
|
* @param taskType 任务类型
|
||||||
|
* @param taskDeploy object
|
||||||
|
* @return 是否有效
|
||||||
|
*/
|
||||||
|
Boolean deployValid(String taskType,TaskDeploy taskDeploy);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置id查询任务
|
||||||
|
* @param authId 配置id
|
||||||
|
* @return 任务
|
||||||
|
*/
|
||||||
|
TaskDeploy findDeployByAuth(String authId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
* @param taskDeploy 更新信息
|
||||||
|
*/
|
||||||
|
void updateDeploy(TaskDeploy taskDeploy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单个信息
|
||||||
|
* @param deployId pipelineDeployId
|
||||||
|
* @return deploy信息
|
||||||
|
*/
|
||||||
|
@FindOne
|
||||||
|
TaskDeploy findOneDeploy(String deployId) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有信息
|
||||||
|
* @return deploy信息集合
|
||||||
|
*/
|
||||||
|
@FindAll
|
||||||
|
List<TaskDeploy> findAllDeploy() ;
|
||||||
|
|
||||||
|
@FindList
|
||||||
|
List<TaskDeploy> findAllDeployList(List<String> idList);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package cd.casic.module.process.task.message.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class TaskMessage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流水线id
|
||||||
|
*/
|
||||||
|
private String pipelineId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收人
|
||||||
|
*/
|
||||||
|
private List<String> list;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
private Map<String, Object> map;
|
||||||
|
|
||||||
|
public TaskMessage() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskMessage(String pipelineId, List<String> list, Map<String, Object> map) {
|
||||||
|
this.pipelineId = pipelineId;
|
||||||
|
this.list = list;
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPipelineId() {
|
||||||
|
return pipelineId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPipelineId(String pipelineId) {
|
||||||
|
this.pipelineId = pipelineId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<String> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMap(Map<String, Object> map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
|||||||
|
package cd.casic.module.process.task.message.model;
|
||||||
|
|
||||||
|
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||||
|
import io.tiklab.toolkit.join.annotation.Join;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
/**
|
||||||
|
* 任务消息类型模型
|
||||||
|
*/
|
||||||
|
//@ApiModel
|
||||||
|
@Join
|
||||||
|
@Mapper
|
||||||
|
public class TaskMessageType {
|
||||||
|
|
||||||
|
//@ApiProperty(name = "id",desc = "id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskId",desc = "任务id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskType",desc="消息类型")
|
||||||
|
private String taskType;
|
||||||
|
|
||||||
|
//@ApiProperty(name="typeList",desc="site:站内信 sms:短信发送 wechat:微信 mail:邮箱发送")
|
||||||
|
private List<String> typeList;
|
||||||
|
|
||||||
|
//@ApiProperty(name="userList",desc="接收人信息")
|
||||||
|
private List<TaskMessageUser> userList;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTypeList() {
|
||||||
|
return typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeList(List<String> typeList) {
|
||||||
|
this.typeList = typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TaskMessageUser> getUserList() {
|
||||||
|
return userList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserList(List<TaskMessageUser> userList) {
|
||||||
|
this.userList = userList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(String taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskType() {
|
||||||
|
return taskType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskType(String taskType) {
|
||||||
|
this.taskType = taskType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package cd.casic.module.process.task.message.model;
|
||||||
|
|
||||||
|
import io.tiklab.toolkit.beans.annotation.Mapper;
|
||||||
|
import io.tiklab.toolkit.beans.annotation.Mapping;
|
||||||
|
import io.tiklab.toolkit.beans.annotation.Mappings;
|
||||||
|
import io.tiklab.toolkit.join.annotation.Join;
|
||||||
|
import io.tiklab.toolkit.join.annotation.JoinQuery;
|
||||||
|
import io.tiklab.user.user.model.User;
|
||||||
|
/**
|
||||||
|
* 任务消息接收人模型
|
||||||
|
*/
|
||||||
|
//@ApiModel
|
||||||
|
@Join
|
||||||
|
@Mapper
|
||||||
|
public class TaskMessageUser {
|
||||||
|
|
||||||
|
//@ApiProperty(name="messageId",desc="配置id")
|
||||||
|
private String messageId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskId",desc="类型")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="user",desc="用户",required = true)
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(source = "user.id",target = "userId")
|
||||||
|
})
|
||||||
|
@JoinQuery(key = "id")
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
//@ApiProperty(name="receiveType",desc="接收类型 1.全部 2.仅成功 3.仅失败")
|
||||||
|
private int receiveType;
|
||||||
|
|
||||||
|
public String getMessageId() {
|
||||||
|
return messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageId(String messageId) {
|
||||||
|
this.messageId = messageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(String taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReceiveType() {
|
||||||
|
return receiveType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceiveType(int receiveType) {
|
||||||
|
this.receiveType = receiveType;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package cd.casic.module.process.task.message.service;
|
||||||
|
|
||||||
|
import io.tiklab.arbess.task.message.model.TaskMessageType;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindAll;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindList;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindOne;
|
||||||
|
import io.tiklab.toolkit.join.annotation.JoinProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务消息类型服务接口
|
||||||
|
*/
|
||||||
|
@JoinProvider(model = TaskMessageType.class)
|
||||||
|
public interface TaskMessageTypeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
* @param taskMessageType message信息
|
||||||
|
*/
|
||||||
|
void createMessage(TaskMessageType taskMessageType) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务
|
||||||
|
* @param taskId 任务id
|
||||||
|
*/
|
||||||
|
void deleteAllMessage(String taskId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否存在消息配置
|
||||||
|
* @return 不存在的消息配置
|
||||||
|
*/
|
||||||
|
List<String> messageSendType();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置id查询消息类型
|
||||||
|
* @param taskId 配置id
|
||||||
|
* @return 消息
|
||||||
|
*/
|
||||||
|
TaskMessageType findMessage(String taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param messageId messageId
|
||||||
|
*/
|
||||||
|
void deleteMessage(String messageId) ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新信息
|
||||||
|
* @param taskMessageType 信息
|
||||||
|
*/
|
||||||
|
void updateMessage(TaskMessageType taskMessageType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单个信息
|
||||||
|
* @param messageId pipelineMessageId
|
||||||
|
* @return message信息
|
||||||
|
*/
|
||||||
|
@FindOne
|
||||||
|
TaskMessageType findOneMessage(String messageId) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有信息
|
||||||
|
* @return message信息集合
|
||||||
|
*/
|
||||||
|
@FindAll
|
||||||
|
List<TaskMessageType> findAllMessage() ;
|
||||||
|
|
||||||
|
@FindList
|
||||||
|
List<TaskMessageType> findAllMessageList(List<String> idList);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package cd.casic.module.process.task.message.service;
|
||||||
|
|
||||||
|
import io.tiklab.arbess.task.message.model.TaskMessageUser;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindAll;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindList;
|
||||||
|
import io.tiklab.toolkit.join.annotation.FindOne;
|
||||||
|
import io.tiklab.toolkit.join.annotation.JoinProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息接收人服务接口
|
||||||
|
*/
|
||||||
|
@JoinProvider(model = TaskMessageUser.class)
|
||||||
|
public interface TaskMessageUserService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建
|
||||||
|
* @param taskMessageUser message信息
|
||||||
|
* @return messageId
|
||||||
|
*/
|
||||||
|
String createMessage(TaskMessageUser taskMessageUser) ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加所有接收人
|
||||||
|
* @param userMessages 接收人信息
|
||||||
|
* @param taskId 任务id
|
||||||
|
*/
|
||||||
|
void createAllMessage(List<TaskMessageUser> userMessages, String taskId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有发送人
|
||||||
|
* @param taskId 任务id
|
||||||
|
* @return 发送人
|
||||||
|
*/
|
||||||
|
List<TaskMessageUser> findAllUserMessage(String taskId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务
|
||||||
|
* @param taskId 配置id
|
||||||
|
*/
|
||||||
|
void deleteAllMessage(String taskId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param messageId messageId
|
||||||
|
*/
|
||||||
|
void deleteMessage(String messageId) ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新信息
|
||||||
|
* @param taskMessageUser 信息
|
||||||
|
*/
|
||||||
|
void updateMessage(TaskMessageUser taskMessageUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单个信息
|
||||||
|
* @param messageId pipelineMessageId
|
||||||
|
* @return message信息
|
||||||
|
*/
|
||||||
|
@FindOne
|
||||||
|
TaskMessageUser findOneMessage(String messageId) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有信息
|
||||||
|
* @return message信息集合
|
||||||
|
*/
|
||||||
|
@FindAll
|
||||||
|
List<TaskMessageUser> findAllMessage() ;
|
||||||
|
|
||||||
|
@FindList
|
||||||
|
List<TaskMessageUser> findAllMessageList(List<String> idList);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package cd.casic.module.process.task.task.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流水线日志
|
||||||
|
*/
|
||||||
|
|
||||||
|
//@Entity
|
||||||
|
//@Table(name="pip_task_instance")
|
||||||
|
@Data
|
||||||
|
public class TaskInstanceEntity {
|
||||||
|
|
||||||
|
//日志id
|
||||||
|
// @Id
|
||||||
|
// @GeneratorValue(length = 12)
|
||||||
|
// @Column(name = "id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
// @Column(name = "instance_id")
|
||||||
|
private String instanceId;
|
||||||
|
|
||||||
|
//运行类型
|
||||||
|
// @Column(name = "task_type")
|
||||||
|
private String taskType ;
|
||||||
|
|
||||||
|
// @Column(name = "task_sort")
|
||||||
|
private int taskSort ;
|
||||||
|
|
||||||
|
//运行日志
|
||||||
|
// @Column(name = "log_address")
|
||||||
|
private String logAddress;
|
||||||
|
|
||||||
|
//运行时间
|
||||||
|
// @Column(name = "run_time")
|
||||||
|
private int runTime;
|
||||||
|
|
||||||
|
//运行状态
|
||||||
|
// @Column(name = "run_state")
|
||||||
|
private String runState;
|
||||||
|
|
||||||
|
//阶段id
|
||||||
|
// @Column(name = "stages_id")
|
||||||
|
private String stagesId;
|
||||||
|
|
||||||
|
//任务名称
|
||||||
|
// @Column(name = "task_name")
|
||||||
|
private String taskName;
|
||||||
|
|
||||||
|
// @Column(name = "postprocess_id")
|
||||||
|
private String postprocessId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,145 @@
|
|||||||
|
package cd.casic.module.process.task.task.service;
|
||||||
|
|
||||||
|
import cd.casic.ci.commons.bean.engine.job.TaskInstance;
|
||||||
|
import cd.casic.ci.commons.bean.engine.job.Tasks;
|
||||||
|
import cd.casic.ci.commons.bean.process.setting.HostGroup;
|
||||||
|
import cd.casic.ci.commons.bean.support.deploy.TaskDeploy;
|
||||||
|
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
||||||
|
import cd.casic.ci.commons.bean.utils.PipelineFileUtil;
|
||||||
|
import cd.casic.module.process.engine.task.TasksExecService;
|
||||||
|
import cd.casic.module.process.engine.task.TasksInstanceService;
|
||||||
|
import cd.casic.module.process.support.util.util.PipelineFinal;
|
||||||
|
import cd.casic.module.process.task.deploy.service.TaskDeployInstanceService;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TasksExecServiceImpl implements TasksExecService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TasksInstanceService tasksInstanceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TaskDeployInstanceService taskDeployInstanceService;
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(TasksExecServiceImpl.class);
|
||||||
|
|
||||||
|
//任务id与任务实例id关系
|
||||||
|
public static Map<String , String> taskIdOrTaskInstanceId = new HashMap<>();
|
||||||
|
|
||||||
|
//任务实例id与任务实例关系
|
||||||
|
public static Map<String, TaskInstance> taskOrTaskInstance = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createTaskExecInstance(Tasks task, String instanceId, int type, String logPath){
|
||||||
|
TaskInstance instance = new TaskInstance();
|
||||||
|
if (type == 1){
|
||||||
|
instance.setInstanceId(instanceId);
|
||||||
|
}
|
||||||
|
if (type == 2) {
|
||||||
|
instance.setStagesId(instanceId);
|
||||||
|
}
|
||||||
|
if (type == 3) {
|
||||||
|
instance.setPostprocessId(instanceId);
|
||||||
|
}
|
||||||
|
instance.setRunState(PipelineFinal.RUN_WAIT);
|
||||||
|
instance.setTaskName(task.getTaskName());
|
||||||
|
instance.setTaskType(task.getTaskType());
|
||||||
|
instance.setTaskSort(task.getTaskSort());
|
||||||
|
|
||||||
|
String taskInstanceId = tasksInstanceService.createTaskInstance(instance);
|
||||||
|
instance.setId(taskInstanceId);
|
||||||
|
//日志文件地址
|
||||||
|
String fileAddress = logPath +"/"+ taskInstanceId + ".log";
|
||||||
|
instance.setLogAddress(fileAddress);
|
||||||
|
PipelineFileUtil.createFile(fileAddress);
|
||||||
|
tasksInstanceService.updateTaskInstance(instance);
|
||||||
|
putTaskOrTaskInstance(taskInstanceId,instance);
|
||||||
|
taskIdOrTaskInstanceId.put(task.getTaskId(),taskInstanceId);
|
||||||
|
|
||||||
|
|
||||||
|
return taskInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createDeployInstance(Tasks task,String taskInstanceId){
|
||||||
|
if (task.getTaskType().equals(PipelineFinal.TASK_DEPLOY_LINUX)){
|
||||||
|
String object = JSON.toJSONString(task.getTask());
|
||||||
|
TaskDeploy taskDeploy = JSON.parseObject(object, TaskDeploy.class);
|
||||||
|
if ( taskDeploy.getAuthType() == 2){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String hostType = taskDeploy.getHostType();
|
||||||
|
if (!"hostGroup".equals(hostType)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<HostGroup> hostGroupList = taskDeploy.getHostGroupList();
|
||||||
|
if (Objects.isNull(hostGroupList)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < hostGroupList.size(); i++) {
|
||||||
|
HostGroup hostGroup = hostGroupList.get(i);
|
||||||
|
String format = String.format("第%s批次", i + 1);
|
||||||
|
TaskDeployInstance taskDeployInstance = new TaskDeployInstance(hostGroup.getTaskInstanceId(),taskInstanceId);
|
||||||
|
taskDeployInstance.setName(format);
|
||||||
|
taskDeployInstance.setSort(i+1);
|
||||||
|
taskDeployInstanceService.createDeployInstance(taskDeployInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskInstance findTaskInstance(String taskInstanceId){
|
||||||
|
return taskOrTaskInstance.get(taskInstanceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String findTaskInstanceId(String taskId){
|
||||||
|
return taskIdOrTaskInstanceId.get(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putTaskOrTaskInstance(String taskInstanceId ,TaskInstance taskInstance ){
|
||||||
|
taskOrTaskInstance.put(taskInstanceId,taskInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,459 @@
|
|||||||
|
package cd.casic.module.process.task.task.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cd.casic.ci.commons.bean.engine.job.TaskInstance;
|
||||||
|
import cd.casic.ci.commons.bean.engine.job.TaskInstanceQuery;
|
||||||
|
import cd.casic.ci.commons.bean.engine.postprocess.PostprocessInstance;
|
||||||
|
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.module.process.engine.task.TasksInstanceService;
|
||||||
|
import cd.casic.module.process.engine.task.dao.TaskInstanceDao;
|
||||||
|
import cd.casic.module.process.support.postprocess.service.PostprocessInstanceService;
|
||||||
|
import cd.casic.module.process.support.util.util.PipelineFinal;
|
||||||
|
|
||||||
|
import cd.casic.module.process.task.deploy.model.TaskDeployInstanceQuery;
|
||||||
|
import cd.casic.module.process.task.deploy.service.TaskDeployInstanceService;
|
||||||
|
import cd.casic.module.process.task.task.entity.TaskInstanceEntity;
|
||||||
|
import cd.casic.module.process.toolkit.beans.BeanMapper;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务执行实例服务接口
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
//@Exporter
|
||||||
|
public class TasksInstanceServiceImpl implements TasksInstanceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TaskInstanceDao taskInstanceDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PostprocessInstanceService postInstanceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TaskDeployInstanceService taskDeployInstanceService;
|
||||||
|
|
||||||
|
public static Map<String, TaskInstance> taskInstanceMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createTaskInstance(TaskInstance taskInstance) {
|
||||||
|
TaskInstanceEntity instanceEntity = BeanMapper.map(taskInstance, TaskInstanceEntity.class);
|
||||||
|
return taskInstanceDao.createInstance(instanceEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAllInstanceInstance(String instanceId) {
|
||||||
|
List<TaskInstance> allInstanceInstance = findAllInstanceInstance(instanceId);
|
||||||
|
if (allInstanceInstance.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (TaskInstance instance : allInstanceInstance) {
|
||||||
|
String taskInstanceId = instance.getId();
|
||||||
|
deleteTaskInstance(taskInstanceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> findAllInstanceLogs(String instanceId){
|
||||||
|
List<TaskInstance> allInstanceInstance = findAllInstanceInstance(instanceId);
|
||||||
|
if (allInstanceInstance.isEmpty()){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
for (TaskInstance taskInstance : allInstanceInstance) {
|
||||||
|
String runLog = taskInstance.getLogAddress();
|
||||||
|
String readFile = PipelineFileUtil.readFile(runLog, 0);
|
||||||
|
if (Objects.isNull(readFile)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.add(readFile + "\n");
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAllStageInstance(String stageId) {
|
||||||
|
List<TaskInstance> allStageInstance = findAllStageInstance(stageId);
|
||||||
|
if (allStageInstance.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (TaskInstance instance : allStageInstance) {
|
||||||
|
String instanceId = instance.getId();
|
||||||
|
deleteTaskInstance(instanceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TaskInstance findOneTaskInstance(String taskInstanceId) {
|
||||||
|
TaskInstanceEntity taskInstanceEntity = taskInstanceDao.findOne(taskInstanceId);
|
||||||
|
return BeanMapper.map(taskInstanceEntity, TaskInstance.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTaskInstance(TaskInstance taskInstance) {
|
||||||
|
TaskInstanceEntity instance = BeanMapper.map(taskInstance, TaskInstanceEntity.class);
|
||||||
|
taskInstanceDao.updateInstance(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer readLogLength= 600;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskInstance> findAllInstanceInstance(String instanceId) {
|
||||||
|
|
||||||
|
List<TaskInstanceEntity> pipelineInstance = taskInstanceDao.findPipelineInstance(instanceId);
|
||||||
|
List<TaskInstance> allInstance = BeanMapper.mapList(pipelineInstance, TaskInstance.class);
|
||||||
|
if (Objects.isNull(allInstance) || allInstance.isEmpty()){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
allInstance.sort(Comparator.comparing(TaskInstance::getTaskSort));
|
||||||
|
|
||||||
|
// 没有正在运行的任务时查询所有日志
|
||||||
|
TaskInstance taskInstance1 = allInstance.get(allInstance.size() - 1);
|
||||||
|
if (!taskInstance1.getRunState().equals(PipelineFinal.RUN_RUN)){
|
||||||
|
readLogLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TaskInstance> list = new ArrayList<>();
|
||||||
|
for (TaskInstance instance : allInstance) {
|
||||||
|
String taskInstanceId = instance.getId();
|
||||||
|
|
||||||
|
TaskInstance taskInstance = taskInstanceMap.get(taskInstanceId);
|
||||||
|
if (!Objects.isNull(taskInstance)) {
|
||||||
|
int time = taskInstance.getRunTime();
|
||||||
|
if (time == 0){
|
||||||
|
time = 1;
|
||||||
|
}
|
||||||
|
instance.setRunTime(time);
|
||||||
|
// if (!StringUtils.isEmpty(instance.getRunLog())){
|
||||||
|
// instance.setRunLog(instance.getRunLog() + taskInstance.getRunLog());
|
||||||
|
// }else {
|
||||||
|
// instance.setRunLog(taskInstance.getRunLog());
|
||||||
|
// }
|
||||||
|
instance.setRunState(PipelineFinal.RUN_RUN);
|
||||||
|
}
|
||||||
|
String logAddress = instance.getLogAddress();
|
||||||
|
String readFile = PipelineFileUtil.readFile(logAddress, readLogLength);
|
||||||
|
String time = PipelineUtil.formatDateTime(instance.getRunTime());
|
||||||
|
instance.setRunTimeDate(time);
|
||||||
|
instance.setRunLog(readFile);
|
||||||
|
list.add(instance);
|
||||||
|
}
|
||||||
|
TaskInstance taskInstance = findPostPipelineRunMessage(instanceId);
|
||||||
|
if (!Objects.isNull(taskInstance)){
|
||||||
|
list.add(list.size(),taskInstance);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TaskInstance findPostPipelineRunMessage(String instanceId){
|
||||||
|
List<PostprocessInstance> postInstanceList = postInstanceService.findPipelinePostInstance(instanceId);;
|
||||||
|
|
||||||
|
if (Objects.isNull(postInstanceList) || postInstanceList.isEmpty()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int runTime = 0;
|
||||||
|
TaskInstance taskInstances4 = new TaskInstance();
|
||||||
|
StringBuilder runLog = new StringBuilder();
|
||||||
|
for (PostprocessInstance postprocessInstance : postInstanceList) {
|
||||||
|
String postInstanceId = postprocessInstance.getId();
|
||||||
|
List<TaskInstanceEntity> postInstance = taskInstanceDao.findPostInstance(postInstanceId);
|
||||||
|
if (Objects.isNull(postInstance) || Objects.equals(postInstance.size(),0)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//任务是否在运行中
|
||||||
|
String taskInstanceId = postInstance.get(0).getId();
|
||||||
|
TaskInstance taskInstance = taskInstanceMap.get(taskInstanceId);
|
||||||
|
|
||||||
|
String readFile = PipelineFileUtil.readFile(taskInstance.getLogAddress(), readLogLength);
|
||||||
|
runTime = runTime + taskInstance.getRunTime();
|
||||||
|
runLog.append(readFile).append("\n");
|
||||||
|
taskInstances4.setRunState(taskInstance.getRunState());
|
||||||
|
taskInstances4.setPostprocessId(postInstanceId);
|
||||||
|
taskInstances4.setLogAddress(postprocessInstance.getPostAddress());
|
||||||
|
}
|
||||||
|
taskInstances4.setRunLog(runLog.toString());
|
||||||
|
String runState = taskInstances4.getRunState();
|
||||||
|
if (Objects.equals(runTime,0) &&
|
||||||
|
!Objects.isNull(runState) &&
|
||||||
|
!Objects.equals(runState,PipelineFinal.RUN_RUN) &&
|
||||||
|
!Objects.equals(runState,PipelineFinal.RUN_HALT)){
|
||||||
|
runTime = 1;
|
||||||
|
}
|
||||||
|
String time = PipelineUtil.formatDateTime(runTime);
|
||||||
|
taskInstances4.setRunTimeDate(time);
|
||||||
|
taskInstances4.setRunTime(runTime);
|
||||||
|
taskInstances4.setTaskType("post");
|
||||||
|
taskInstances4.setTaskName("后置处理");
|
||||||
|
taskInstances4.setId("post");
|
||||||
|
return taskInstances4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskInstance> findStagePostRunMessage(String id){
|
||||||
|
List<PostprocessInstance> taskPostInstance = postInstanceService.findPipelinePostInstance(id);
|
||||||
|
List<TaskInstance> list = new ArrayList<>();
|
||||||
|
for (PostprocessInstance postprocessInstance : taskPostInstance) {
|
||||||
|
String postInstanceId = postprocessInstance.getId();
|
||||||
|
List<TaskInstanceEntity> postInstanceEntityList = taskInstanceDao.findPostInstance(postInstanceId);
|
||||||
|
TaskInstance instance = BeanMapper.map(postInstanceEntityList.get(0), TaskInstance.class);
|
||||||
|
String taskInstanceId = instance.getId();
|
||||||
|
TaskInstance taskInstance = taskInstanceMap.get(taskInstanceId);
|
||||||
|
if (Objects.isNull(taskInstance)){
|
||||||
|
String readFile = PipelineFileUtil.readFile(instance.getLogAddress(), 0);
|
||||||
|
instance.setRunLog(readFile);
|
||||||
|
}else {
|
||||||
|
instance.setRunTime(taskInstance.getRunTime());
|
||||||
|
if (!StringUtils.isEmpty(instance.getRunLog())){
|
||||||
|
instance.setRunLog(instance.getRunLog() + taskInstance.getRunLog());
|
||||||
|
}else {
|
||||||
|
instance.setRunLog(taskInstance.getRunLog());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String time = PipelineUtil.formatDateTime(instance.getRunTime());
|
||||||
|
instance.setRunTimeDate(time);
|
||||||
|
list.add(instance);
|
||||||
|
}
|
||||||
|
list.sort(Comparator.comparing(TaskInstance::getTaskSort));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskInstance> findAllStageInstance(String stageId) {
|
||||||
|
List<TaskInstanceEntity> pipelineInstance = taskInstanceDao.findStageInstance(stageId);
|
||||||
|
List<TaskInstance> allInstance = BeanMapper.mapList(pipelineInstance, TaskInstance.class);
|
||||||
|
if (Objects.isNull(allInstance) || allInstance.isEmpty()){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
int allTaskRunTime = 0;
|
||||||
|
for (TaskInstance instance : allInstance) {
|
||||||
|
String taskInstanceId = instance.getId();
|
||||||
|
|
||||||
|
TaskDeployInstanceQuery deployInstanceQuery = new TaskDeployInstanceQuery();
|
||||||
|
deployInstanceQuery.setTaskInstanceId(taskInstanceId);
|
||||||
|
List<TaskDeployInstance> allDeployInstanceList = taskDeployInstanceService.findAllDeployInstanceList(deployInstanceQuery);
|
||||||
|
List<TaskDeployInstance> list = allDeployInstanceList.stream().peek(deployInstance -> {
|
||||||
|
String runTime = deployInstance.getRunTime();
|
||||||
|
if (StringUtils.isEmpty(runTime)) {
|
||||||
|
runTime = "0";
|
||||||
|
}
|
||||||
|
String s = PipelineUtil.formatDateTime(Long.parseLong(runTime));
|
||||||
|
deployInstance.setRunTime(s);
|
||||||
|
}).toList();
|
||||||
|
instance.setDeployInstanceList(list);
|
||||||
|
|
||||||
|
TaskInstance taskInstance = taskInstanceMap.get(taskInstanceId);
|
||||||
|
|
||||||
|
if (!Objects.isNull(taskInstance)){
|
||||||
|
int time = taskInstance.getRunTime() == 0 ? 1 : taskInstance.getRunTime();
|
||||||
|
instance.setRunTime(time);
|
||||||
|
instance.setRunState(taskInstance.getRunState());
|
||||||
|
}
|
||||||
|
// if (Objects.isNull(taskInstance)){
|
||||||
|
// String logAddress = instance.getLogAddress();
|
||||||
|
// String readFile = PipelineFileUtil.readFile(logAddress, 2000);
|
||||||
|
// instance.setRunLog(readFile);
|
||||||
|
// }else {
|
||||||
|
// int time = taskInstance.getRunTime();
|
||||||
|
// if (time == 0){
|
||||||
|
// time = 1;
|
||||||
|
// }
|
||||||
|
// if (StringUtils.isEmpty(taskInstance.getRunLog()) ){
|
||||||
|
// String logAddress = instance.getLogAddress();
|
||||||
|
// String readFile = PipelineFileUtil.readFile(logAddress, readLogLength);
|
||||||
|
// instance.setRunLog(readFile);
|
||||||
|
// }else {
|
||||||
|
// instance.setRunLog(taskInstance.getRunLog());
|
||||||
|
// }
|
||||||
|
// instance.setRunTime(time);
|
||||||
|
// instance.setRunState(taskInstance.getRunState());
|
||||||
|
// }
|
||||||
|
String logAddress = instance.getLogAddress();
|
||||||
|
String readFile = PipelineFileUtil.readFile(logAddress, readLogLength);
|
||||||
|
instance.setRunLog(readFile);
|
||||||
|
|
||||||
|
String time = PipelineUtil.formatDateTime(instance.getRunTime());
|
||||||
|
instance.setRunTimeDate(time);
|
||||||
|
allTaskRunTime = allTaskRunTime + instance.getRunTime();
|
||||||
|
}
|
||||||
|
return allInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean readCommandExecResult(Process process , String enCode, Map<String,String> error,String taskId) {
|
||||||
|
boolean state = true;
|
||||||
|
//指定编码
|
||||||
|
if (!PipelineUtil.isNoNull(enCode)){
|
||||||
|
int systemType = PipelineUtil.findSystemType();
|
||||||
|
if (systemType == 1){
|
||||||
|
enCode = PipelineFinal.GBK;
|
||||||
|
}else {
|
||||||
|
enCode = PipelineFinal.UTF_8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//转换流
|
||||||
|
InputStream inputStream = process.getInputStream();
|
||||||
|
InputStream errInputStream = process.getErrorStream();
|
||||||
|
|
||||||
|
InputStreamReader inputStreamReader ;
|
||||||
|
BufferedReader bufferedReader ;
|
||||||
|
if (inputStream == null){
|
||||||
|
inputStreamReader = PipelineUtil.encode(errInputStream, enCode);
|
||||||
|
}else {
|
||||||
|
inputStreamReader = PipelineUtil.encode(inputStream, enCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
String s;
|
||||||
|
bufferedReader = new BufferedReader(inputStreamReader);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
//读取执行信息
|
||||||
|
while ((s = bufferedReader.readLine()) != null) {
|
||||||
|
String s1 = validStatus(s, error);
|
||||||
|
if (!Objects.isNull(s1)){
|
||||||
|
state = false ;
|
||||||
|
writeExecLog(taskId, s1);
|
||||||
|
}
|
||||||
|
writeExecLog(taskId, s);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//读取err执行信息
|
||||||
|
inputStreamReader = PipelineUtil.encode(errInputStream, enCode);
|
||||||
|
bufferedReader = new BufferedReader(inputStreamReader);
|
||||||
|
|
||||||
|
while ((s = bufferedReader.readLine()) != null) {
|
||||||
|
String s1 = validStatus(s, error);
|
||||||
|
if (!Objects.isNull(s1)){
|
||||||
|
state = false ;
|
||||||
|
writeExecLog(taskId, s1);
|
||||||
|
}
|
||||||
|
writeExecLog(taskId, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭
|
||||||
|
inputStreamReader.close();
|
||||||
|
bufferedReader.close();
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
writeExecLog(taskId, e.getMessage());
|
||||||
|
state = false;
|
||||||
|
}
|
||||||
|
process.destroy();
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 效验日志状态
|
||||||
|
* @param s 日志
|
||||||
|
* @param errors 错误状态
|
||||||
|
* @return null 正确 other:错误
|
||||||
|
*/
|
||||||
|
public String validStatus(String s,Map<String,String> errors){
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> errorString : errors.entrySet()) {
|
||||||
|
String key = errorString.getKey();
|
||||||
|
if (!s.contains(key)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return errorString.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeExecLog(String taskId, String execLog){
|
||||||
|
if(!PipelineUtil.isNoNull(execLog)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TasksExecServiceImpl tasksExecService = new TasksExecServiceImpl();
|
||||||
|
String taskInstanceId = tasksExecService.findTaskInstanceId(taskId);
|
||||||
|
TaskInstance taskInstance2 = tasksExecService.findTaskInstance(taskInstanceId);
|
||||||
|
if (Objects.isNull(taskInstance2)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String execInstance = taskInstance2.getRunLog();
|
||||||
|
|
||||||
|
if (!PipelineUtil.isNoNull(execInstance)){
|
||||||
|
taskInstance2.setRunLog(execLog);
|
||||||
|
}else {
|
||||||
|
taskInstance2.setRunLog(execInstance +"\n"+ execLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
//长度过长写入文件中
|
||||||
|
String runInstance = taskInstance2.getRunLog();
|
||||||
|
if (runInstance.length() > 9000){
|
||||||
|
String logAddress = taskInstance2.getLogAddress();
|
||||||
|
PipelineFileUtil.logWriteFile(runInstance,logAddress);
|
||||||
|
taskInstance2.setRunLog(null);
|
||||||
|
}
|
||||||
|
tasksExecService.putTaskOrTaskInstance(taskInstanceId, taskInstance2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeAllExecLog(String taskId, String execLog){
|
||||||
|
if(!PipelineUtil.isNoNull(execLog)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TasksExecServiceImpl tasksExecService = new TasksExecServiceImpl();
|
||||||
|
String taskInstanceId = tasksExecService.findTaskInstanceId(taskId);
|
||||||
|
TaskInstance taskInstance1 = tasksExecService.findTaskInstance(taskInstanceId);
|
||||||
|
String execInstance = taskInstance1.getRunLog();
|
||||||
|
|
||||||
|
if (!PipelineUtil.isNoNull(execInstance)){
|
||||||
|
taskInstance1.setRunLog(execLog);
|
||||||
|
}else {
|
||||||
|
taskInstance1.setRunLog(execInstance +"\n"+ execLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
//长度过长写入文件中
|
||||||
|
String runInstance = taskInstance1.getRunLog();
|
||||||
|
String logAddress = taskInstance1.getLogAddress();
|
||||||
|
PipelineFileUtil.logWriteFile(runInstance,logAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务执行实例
|
||||||
|
* @param taskInstanceId 任务实例id
|
||||||
|
*/
|
||||||
|
private void deleteTaskInstance(String taskInstanceId){
|
||||||
|
taskInstanceDao.deleteInstance(taskInstanceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskInstance> findAllTaskInstance() {
|
||||||
|
List<TaskInstanceEntity> allInstance = taskInstanceDao.findAllInstance();
|
||||||
|
return BeanMapper.mapList(allInstance, TaskInstance.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskInstance> findAllInstanceList(List<String> idList) {
|
||||||
|
List<TaskInstanceEntity> pipelineInstanceList = taskInstanceDao.findAllInstanceList(idList);
|
||||||
|
return BeanMapper.mapList(pipelineInstanceList, TaskInstance.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TaskInstance> findTaskInstanceList(TaskInstanceQuery query){
|
||||||
|
List<TaskInstanceEntity> pipelineInstanceList = taskInstanceDao.findTaskInstanceList(query);
|
||||||
|
if (pipelineInstanceList == null || pipelineInstanceList.isEmpty()){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return BeanMapper.mapList(pipelineInstanceList,TaskInstance.class);
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ 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.definition.Pipeline;
|
||||||
import cd.casic.ci.commons.bean.process.instance.PipelineInstance;
|
import cd.casic.ci.commons.bean.process.instance.PipelineInstance;
|
||||||
import cd.casic.ci.commons.bean.process.stage.StageInstance;
|
import cd.casic.ci.commons.bean.process.stage.StageInstance;
|
||||||
|
|
||||||
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
import cd.casic.ci.commons.bean.support.deploy.TaskDeployInstance;
|
||||||
import cd.casic.ci.commons.bean.utils.PipelineFileUtil;
|
import cd.casic.ci.commons.bean.utils.PipelineFileUtil;
|
||||||
import cd.casic.ci.commons.bean.utils.PipelineUtil;
|
import cd.casic.ci.commons.bean.utils.PipelineUtil;
|
||||||
@ -19,6 +20,10 @@ import cd.casic.module.process.support.postprocess.service.PostprocessInstanceSe
|
|||||||
import cd.casic.module.process.support.util.PipelineUtilService;
|
import cd.casic.module.process.support.util.PipelineUtilService;
|
||||||
import cd.casic.module.process.support.util.util.PipelineFinal;
|
import cd.casic.module.process.support.util.util.PipelineFinal;
|
||||||
import cd.casic.module.process.task.code.service.SpotbugsScanService;
|
import cd.casic.module.process.task.code.service.SpotbugsScanService;
|
||||||
|
import cd.casic.module.process.task.codescan.model.SpotbugsBugSummary;
|
||||||
|
import cd.casic.module.process.task.deploy.service.TaskDeployInstanceService;
|
||||||
|
import cd.casic.module.process.task.message.model.TaskMessage;
|
||||||
|
import cd.casic.module.process.task.task.service.TasksInstanceServiceImpl;
|
||||||
import cd.casic.module.process.task.test.model.MavenTest;
|
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.model.TestOnRelevance;
|
||||||
import cd.casic.module.process.task.test.service.MavenTestService;
|
import cd.casic.module.process.task.test.service.MavenTestService;
|
||||||
@ -70,7 +75,7 @@ public class WebSocketMessageServiceImpl implements WebSocketMessageService {
|
|||||||
PostprocessInstanceService postprocessInstanceService;
|
PostprocessInstanceService postprocessInstanceService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TaskDeployInstanceServiceImpl deployInstanceService;
|
TaskDeployInstanceService deployInstanceService;
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user