v4.1 提交新的模型,但是模型不能运行,如果要运行,把ci-process卸载pom

This commit is contained in:
mian-bin@hotmail.com 2025-03-28 14:22:05 +08:00
parent 42759b8f40
commit 76ce3d1e2e
5 changed files with 97 additions and 135 deletions

View File

@ -25,6 +25,11 @@ public interface IModelTemplate {
@Schema(title = "变量", required = true)
Map<String, String> getVariables();
void setTemplate(String template);
void setRef(String ref);
void setVariables(Map<String, String> variables);
/**
* 判读是否来自于模板

View File

@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
@ -34,28 +35,29 @@ import java.util.Map;
@JsonSubTypes.Type(value = VMBuildContainer.class, name = VMBuildContainer.classType)
})
@Getter
@NoArgsConstructor
@AllArgsConstructor
public abstract class Container implements IModelTemplate {
private String id;
private String name;
private List<Element> elements;
private String status;
@Deprecated
private Long startEpoch;
@Deprecated
private Long systemElapsed;
@Deprecated
private Long elementElapsed;
private Boolean canRetry;
private String containerId;
private String containerHashId;
private String startVMStatus;
private Integer executeCount;
private String jobId;
private Boolean containPostTaskFlag;
private Boolean matrixGroupFlag;
private BuildRecordTimeCost timeCost;
private Integer startVMTaskSeq;
protected String id; // seq id
protected String name;
protected List<Element> elements;
protected String status;
@Deprecated(since = "即将被timeCost代替")
protected Long startEpoch;
@Deprecated(since = "即将被timeCost代替")
protected Long systemElapsed; // 系统耗时开机时间
@Deprecated(since = "即将被timeCost代替")
protected Long elementElapsed; // 插件执行耗时
protected Boolean canRetry; // 当前job是否能重试
protected String containerId; // container 流水线唯一ID同seq id
protected String containerHashId; // container 全局唯一ID
protected String startVMStatus;
protected Integer executeCount;
protected String jobId; // 用户自定义id
protected Boolean containPostTaskFlag; // 是否包含post任务
protected Boolean matrixGroupFlag; // 是否为构建矩阵组
protected BuildRecordTimeCost timeCost; // 耗时结果
protected Integer startVMTaskSeq; // 开机任务序号
public void resetBuildOption(int executeCount) {
this.status = null;

View File

@ -3,104 +3,51 @@ package cd.casic.ci.common.pipeline.container;
import cd.casic.ci.common.pipeline.NameAndValue;
import cd.casic.ci.common.pipeline.option.JobControlOption;
import cd.casic.ci.common.pipeline.option.MatrixControlOption;
import cd.casic.ci.common.pipeline.pojo.element.Element;
import cd.casic.ci.common.pipeline.pojo.time.BuildRecordTimeCost;
import io.swagger.v3.oas.annotations.media.Schema;
import kotlin.ReplaceWith;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Authormianbin
* @Packagecd.casic.ci.common.pipeline.container
* @Projectops-pro
* @nameNormalContainer
* @Date2025/03/25 16:54
* @FilenameNormalContainer
* @descriptionTodo
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Schema(title = "流水线模型-普通任务容器")
public class NormalContainer implements Container {
public static final String classType = "normal";
public class NormalContainer extends Container {
public static final String CLASS_TYPE = "normal";
private Boolean enableSkip = false;
@Schema(title = "构建容器序号id", required = false, readOnly = true)
private String id;
@Schema(title = "容器名称", required = true)
private String name;
@Schema(title = "任务集合", required = true)
private List<Element> elements;
@Schema(title = "容器状态", required = false, readOnly = true)
private String status;
@Schema(title = "系统运行时间", required = false, readOnly = true)
@Deprecated
private Long startEpoch;
@Schema(title = "系统耗时(开机时间)", required = false, readOnly = true)
@Deprecated
private Long systemElapsed;
@Schema(title = "插件执行耗时", required = false, readOnly = true)
@Deprecated
private Long elementElapsed;
@Schema(title = "允许可跳过", required = false)
@Deprecated
private Boolean enableSkip;
@Schema(title = "触发条件", required = false)
@Deprecated
private List<NameAndValue> conditions;
@Schema(title = "是否可重试-仅限于构建详情展示重试目前未作为编排的选项暂设置为null不存储", required = false, readOnly = true)
private Boolean canRetry;
@Schema(title = "构建容器顺序ID同id值", required = false, readOnly = true)
private String containerId;
@Schema(title = "容器唯一ID", required = false, readOnly = true)
private String containerHashId;
@Schema(title = "无构建环境-等待运行环境启动的排队最长时间(分钟)", required = false)
@Deprecated
private Integer maxQueueMinutes = 60;
@Schema(title = "无构建环境-运行最长时间(分钟)", required = false)
@Deprecated
private Integer maxRunningMinutes = 1440;
@Schema(title = "流程控制选项", required = true)
private JobControlOption jobControlOption;
@Schema(title = "互斥组", required = false)
private MutexGroup mutexGroup;
@Schema(title = "构建环境启动状态", required = false, readOnly = true)
private String startVMStatus;
@Schema(title = "容器运行次数", required = false, readOnly = true)
private Integer executeCount;
@Schema(title = "用户自定义ID", required = false, hidden = false)
private String jobId;
@Schema(title = "是否包含post任务标识", required = false, readOnly = true)
private Boolean containPostTaskFlag;
@Schema(title = "是否为构建矩阵", required = false, readOnly = true)
private Boolean matrixGroupFlag;
@Schema(title = "各项耗时", required = true)
private BuildRecordTimeCost timeCost;
@Schema(title = "开机任务序号", required = false, readOnly = true)
private Integer startVMTaskSeq;
@Schema(title = "构建矩阵配置项", required = false)
private JobControlOption jobControlOption; // 为了兼容旧数据所以定义为可空以及var
private MutexGroup mutexGroup; // 为了兼容旧数据所以定义为可空以及var
private MatrixControlOption matrixControlOption;
@Schema(title = "所在构建矩阵组的containerHashId分裂后的子容器特有字段", required = false)
private String matrixGroupId;
@Schema(title = "当前矩阵子容器的上下文组合(分裂后的子容器特有字段)", required = false)
private Map<String, String> matrixContext;
@Schema(title = "分裂后的容器集合(分裂后的父容器特有字段)", required = false)
private List<NormalContainer> groupContainers;
@Override
public String getClassType() {
return classType;
return CLASS_TYPE;
}
@Override
public Container getContainerById(String vmSeqId) {
if (id.equals(vmSeqId) || containerId.equals(vmSeqId)) return this;
if (groupContainers != null) {
for (Container container : groupContainers) {
if (container.getId().equals(vmSeqId) || container.getContainerId().equals(vmSeqId)) return container;
if (vmSeqId.equals(id) || vmSeqId.equals(containerId)) {
return this;
}
List<Container> containers = fetchGroupContainers();
if (containers != null) {
for (Container container : containers) {
if (vmSeqId.equals(container.getId()) || vmSeqId.equals(container.getContainerId())) {
return container;
}
}
}
return null;
@ -108,7 +55,7 @@ public class NormalContainer implements Container {
@Override
public void retryFreshMatrixOption() {
groupContainers = new ArrayList<>();
groupContainers = null;
if (matrixControlOption != null) {
matrixControlOption.setFinishCount(null);
matrixControlOption.setTotalCount(null);
@ -117,7 +64,7 @@ public class NormalContainer implements Container {
@Override
public List<Container> fetchGroupContainers() {
return groupContainers != null ? new ArrayList<>(groupContainers) : null;
return groupContainers != null ? List.copyOf(groupContainers) : null;
}
@Override
@ -126,47 +73,23 @@ public class NormalContainer implements Container {
}
@Override
public Boolean containerEnabled() {
return jobControlOption != null ? jobControlOption.getEnable() : true;
public boolean containerEnabled() {
return jobControlOption == null || jobControlOption.getEnable();
}
@Override
public void setContainerEnable(Boolean enable) {
public void setContainerEnable(boolean enable) {
jobControlOption = jobControlOption != null ? jobControlOption.copy(enable) : new JobControlOption(enable);
}
@Override
public void resetBuildOption(int executeCount) {
}
@Override
public void transformCompatibility() {
if (jobControlOption != null && jobControlOption.getTimeoutVar() == null || jobControlOption.getTimeoutVar().isBlank()) {
if (jobControlOption != null && (jobControlOption.getTimeoutVar() == null || jobControlOption.getTimeoutVar().isEmpty())) {
jobControlOption.setTimeoutVar(String.valueOf(jobControlOption.getTimeout()));
}
if (mutexGroup != null && (mutexGroup.getTimeoutVar() == null || mutexGroup.getTimeoutVar().isBlank())) {
if (mutexGroup != null && (mutexGroup.getTimeoutVar() == null || mutexGroup.getTimeoutVar().isEmpty())) {
mutexGroup.setTimeoutVar(String.valueOf(mutexGroup.getTimeout()));
}
}
@Override
public Map<String, Object> genTaskParams() {
return null;
}
@Override
public String getTemplate() {
return null;
}
@Override
public String getRef() {
return null;
}
@Override
public Map<String, String> getVariables() {
return null;
super.transformCompatibility();
}
}

View File

@ -2,6 +2,8 @@ package cd.casic.ci.common.pipeline.container;
import cd.casic.ci.common.pipeline.pojo.BuildFormProperty;
import cd.casic.ci.common.pipeline.pojo.BuildNo;
import cd.casic.ci.common.pipeline.pojo.element.Element;
import cd.casic.ci.common.pipeline.pojo.time.BuildRecordTimeCost;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -21,7 +23,7 @@ import java.util.Map;
@Data
@NoArgsConstructor
@Schema(title = "流水线模型-构建触发容器")
public class TriggerContainer implements Container {
public class TriggerContainer extends Container {
public static final String classType = "trigger";
@Schema(title = "构建容器序号id", required = false, readOnly = true)
@ -94,17 +96,32 @@ public class TriggerContainer implements Container {
}
@Override
public Boolean containerEnabled() {
public boolean containerEnabled() {
return true;
}
@Override
public void setContainerEnable(Boolean enable) {
// No operation needed
public void setContainerEnable(boolean enable) {
}
@Override
public void transformCompatibility() {
// No compatibility transformation needed
}
@Override
public String getTemplate() {
return null;
}
@Override
public String getRef() {
return null;
}
@Override
public Map<String, String> getVariables() {
return null;
}
}

View File

@ -28,7 +28,7 @@ import java.util.Set;
@Data
@NoArgsConstructor
@Schema(title = "流水线模型-虚拟机构建容器")
public class VMBuildContainer implements Container {
public class VMBuildContainer extends Container {
public static final String classType = "vmBuild";
@Schema(title = "构建容器序号id", required = false, readOnly = true)
@ -155,13 +155,13 @@ public class VMBuildContainer implements Container {
}
@Override
public Boolean containerEnabled() {
public boolean containerEnabled() {
return jobControlOption != null ? jobControlOption.getEnable() : true;
}
@Override
public void setContainerEnable(Boolean enable) {
jobControlOption = jobControlOption != null ? jobControlOption.setEnable(enable) : new JobControlOption(enable);
public void setContainerEnable(boolean enable) {
}
@Override
@ -173,4 +173,19 @@ public class VMBuildContainer implements Container {
mutexGroup.setTimeoutVar(String.valueOf(mutexGroup.getTimeout()));
}
}
@Override
public String getTemplate() {
return null;
}
@Override
public String getRef() {
return null;
}
@Override
public Map<String, String> getVariables() {
return null;
}
}