部分接口mock数据,以及请求与返回值对象,pom文件添加pipelineCommon依赖
This commit is contained in:
parent
472d1aee85
commit
2e51102734
@ -148,6 +148,7 @@ public class OpsWebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
// 添加 Token Filter
|
// 添加 Token Filter
|
||||||
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
|
|
||||||
return httpSecurity.build();
|
return httpSecurity.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.req.agent;
|
||||||
|
|
||||||
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
@Data
|
||||||
|
public class AgentQueryReq {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
private String businessType;
|
||||||
|
|
||||||
|
private PageParam pageParam= new PageParam();
|
||||||
|
|
||||||
|
// private List<Order> orderParams = OrderBuilders.instance().desc("createTime").get();
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.req.stage;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.resp.task.TasksResp;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StageReq {
|
||||||
|
//@ApiProperty(name = "stageId",desc="id")
|
||||||
|
private String stageId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "stageName",desc="名称")
|
||||||
|
private String stageName;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "createTime",desc="创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
//@ApiProperty(name="pipelineId",desc="流水线id")
|
||||||
|
private String pipelineId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="stageSort",desc="阶段顺序")
|
||||||
|
private int stageSort;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "parentId",desc="主阶段")
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "code",desc="是否是源码")
|
||||||
|
private boolean code = false;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskValues",desc="阶段任务")
|
||||||
|
private List<TasksResp> taskValues;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "stageList",desc="阶段")
|
||||||
|
private List<StageReq> stageList;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskType",desc="任务类型")
|
||||||
|
private String taskType;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskId",desc="任务id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "values",desc="更新内容")
|
||||||
|
private Object values;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskSort",desc="任务顺序")
|
||||||
|
private int taskSort;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "parallelName",desc="并行阶段名称")
|
||||||
|
private String parallelName;
|
||||||
|
|
||||||
|
// 执行实例id
|
||||||
|
private String instanceId;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.req.trigger;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TriggerQueryReq {
|
||||||
|
//@ApiProperty(name = "name",desc="名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "taskType",desc="类型 81:定时任务")
|
||||||
|
private int taskType;
|
||||||
|
|
||||||
|
private String pipelineId;
|
||||||
|
|
||||||
|
// 状态 1--未执行 2--已执行
|
||||||
|
private String state;
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.req.variable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VariableReq {
|
||||||
|
//@ApiProperty(name="varId",desc="id")
|
||||||
|
private String varId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="createTime",desc="创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
//@ApiProperty(name="varType",desc="类型 str.字符串 single .单选")
|
||||||
|
private String varType;
|
||||||
|
|
||||||
|
//@ApiProperty(name="type",desc="类型 1.全局 2.项目")
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskId",desc="任务id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="pipelineId",desc="流水线id")
|
||||||
|
private String pipelineId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "varKey",desc="名称")
|
||||||
|
private String varKey;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "varValue",desc="默认值")
|
||||||
|
private String varValue;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "varValues",desc="值")
|
||||||
|
private String varValues;
|
||||||
|
|
||||||
|
private List<String> valueList;
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.resp.agent;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AgentResp {
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
private String businessType;
|
||||||
|
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
private Boolean isConnect;
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.resp.task;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TasksResp {
|
||||||
|
//@ApiProperty(name="taskId",desc="配置id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="createTime",desc="创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskType",desc= "类型1-10:源码,10-20:测试,20-30:构建,30-40:部署,40-50:代码扫描,50-60:推送制品")
|
||||||
|
private String taskType;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskSort",desc="顺序")
|
||||||
|
private int taskSort;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskName",desc="顺序")
|
||||||
|
private String taskName;
|
||||||
|
|
||||||
|
//@ApiProperty(name="values",desc="任务")
|
||||||
|
private Object values;
|
||||||
|
|
||||||
|
//@ApiProperty(name="pipeline",desc="流水线id",eg="@selectOne")
|
||||||
|
private String pipelineId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="postprocessId",desc="后置处理id",eg="@selectOne")
|
||||||
|
private String postprocessId;;
|
||||||
|
|
||||||
|
//@ApiProperty(name="stageId",desc="阶段",eg="@selectOne")
|
||||||
|
private String stageId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="task",desc="任务",eg="@selectOne")
|
||||||
|
private Object task;
|
||||||
|
|
||||||
|
// 执行实例id
|
||||||
|
private String instanceId;
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package cd.casic.ci.common.pipeline.resp.variable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class VariableResp {
|
||||||
|
//@ApiProperty(name="varId",desc="id")
|
||||||
|
private String varId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="createTime",desc="创建时间")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
//@ApiProperty(name="varType",desc="类型 str.字符串 single .单选")
|
||||||
|
private String varType;
|
||||||
|
|
||||||
|
//@ApiProperty(name="type",desc="类型 1.全局 2.项目")
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
//@ApiProperty(name="taskId",desc="任务id")
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
//@ApiProperty(name="pipelineId",desc="流水线id")
|
||||||
|
private String pipelineId;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "varKey",desc="名称")
|
||||||
|
private String varKey;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "varValue",desc="默认值")
|
||||||
|
private String varValue;
|
||||||
|
|
||||||
|
//@ApiProperty(name = "varValues",desc="值")
|
||||||
|
private String varValues;
|
||||||
|
|
||||||
|
private List<String> valueList;
|
||||||
|
}
|
@ -43,6 +43,10 @@
|
|||||||
<groupId>cd.casic.boot</groupId>
|
<groupId>cd.casic.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-protection</artifactId>
|
<artifactId>spring-boot-starter-protection</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cd.casic.boot</groupId>
|
||||||
|
<artifactId>module-ci-common-pipeline</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package cd.casic.server.controller;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.req.agent.AgentQueryReq;
|
||||||
|
import cd.casic.ci.common.pipeline.resp.agent.AgentResp;
|
||||||
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import jakarta.annotation.security.PermitAll;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/agent")
|
||||||
|
public class AgentController {
|
||||||
|
@PermitAll
|
||||||
|
@PostMapping(path="/findAgentList")
|
||||||
|
public CommonResult<List<AgentResp>> findAgentList(@RequestBody @NotNull @Valid AgentQueryReq agentQuery){
|
||||||
|
|
||||||
|
// List<Agent> agentList = agentService.findAgentList(agentQuery);
|
||||||
|
String dataStr ="[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"id\": \"c9ae1ff534db\",\n" +
|
||||||
|
" \"name\": \"local\",\n" +
|
||||||
|
" \"ip\": \"127.0.0.1\",\n" +
|
||||||
|
" \"tenantId\": \"default\",\n" +
|
||||||
|
" \"address\": \"local-default\",\n" +
|
||||||
|
" \"businessType\": \"default\",\n" +
|
||||||
|
" \"createTime\": \"2025-05-09 15:41:04\",\n" +
|
||||||
|
" \"displayType\": \"yes\",\n" +
|
||||||
|
" \"connect\": true\n" +
|
||||||
|
" }\n" +
|
||||||
|
"]";
|
||||||
|
JSONArray objects = JSON.parseArray(dataStr);
|
||||||
|
List<AgentResp> data = new ArrayList<>(objects.size());
|
||||||
|
for (Object object : objects) {
|
||||||
|
AgentResp agentResp = JSON.parseObject(JSON.toJSONString(object), AgentResp.class);
|
||||||
|
data.add(agentResp);
|
||||||
|
}
|
||||||
|
return CommonResult.success(data);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,355 @@
|
|||||||
|
package cd.casic.server.controller;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.req.stage.StageReq;
|
||||||
|
import cd.casic.ci.common.pipeline.resp.stage.StageResp;
|
||||||
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
|
||||||
|
import jakarta.annotation.security.PermitAll;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.protocol: http
|
||||||
|
* @pi.groupName: 流水线多阶段控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/stage")
|
||||||
|
public class StageController {
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// StageService stageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.name:创建流水线阶段及任务
|
||||||
|
* @pi.path:/stage/createStage
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type:json
|
||||||
|
* @pi.param: model=stage
|
||||||
|
*/
|
||||||
|
@RequestMapping(path="/createStage",method = RequestMethod.POST)
|
||||||
|
public CommonResult<String> createStagesOrTask(@RequestBody @Valid @NotNull StageReq stage){
|
||||||
|
// String taskId = stageService.createStagesOrTask(stage);
|
||||||
|
String taskId = "";
|
||||||
|
return CommonResult.success(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.name:查询流水线阶段信息
|
||||||
|
* @pi.path:/stage/finAllStage
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type: formdata
|
||||||
|
* @pi.param: name=pipelineId;dataType=string;value=pipelineId;
|
||||||
|
*/
|
||||||
|
@PermitAll
|
||||||
|
@RequestMapping(path="/finAllStage",method = RequestMethod.POST)
|
||||||
|
public CommonResult<List<StageResp>> finAllPipelineTaskOrTask(@NotNull String pipelineId){
|
||||||
|
// List<Stage> tasks = stageService.findAllStagesTask(pipelineId);
|
||||||
|
String taskStr = "[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"36a816ca6cca\",\n" +
|
||||||
|
" \"stageName\": \"源码\",\n" +
|
||||||
|
" \"createTime\": \"2024-11-25 11:09:35\",\n" +
|
||||||
|
" \"pipelineId\": \"a69119cfbbde\",\n" +
|
||||||
|
" \"stageSort\": 1,\n" +
|
||||||
|
" \"parentId\": null,\n" +
|
||||||
|
" \"code\": true,\n" +
|
||||||
|
" \"taskValues\": null,\n" +
|
||||||
|
" \"stageList\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"8cde3a5616e9\",\n" +
|
||||||
|
" \"stageName\": \"源码\",\n" +
|
||||||
|
" \"createTime\": \"2024-11-25 11:09:35\",\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"stageSort\": 1,\n" +
|
||||||
|
" \"parentId\": \"36a816ca6cca\",\n" +
|
||||||
|
" \"code\": false,\n" +
|
||||||
|
" \"taskValues\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"taskId\": \"a68e6052db9f\",\n" +
|
||||||
|
" \"createTime\": \"2024-11-25 11:09:35\",\n" +
|
||||||
|
" \"taskType\": \"git\",\n" +
|
||||||
|
" \"taskSort\": 1,\n" +
|
||||||
|
" \"taskName\": \"通用Git\",\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"8cde3a5616e9\",\n" +
|
||||||
|
" \"task\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"stageList\": null,\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"3b1a5fdd9b6c\",\n" +
|
||||||
|
" \"stageName\": \"阶段-2\",\n" +
|
||||||
|
" \"createTime\": \"2025-03-10 14:51:43\",\n" +
|
||||||
|
" \"pipelineId\": \"a69119cfbbde\",\n" +
|
||||||
|
" \"stageSort\": 2,\n" +
|
||||||
|
" \"parentId\": null,\n" +
|
||||||
|
" \"code\": false,\n" +
|
||||||
|
" \"taskValues\": null,\n" +
|
||||||
|
" \"stageList\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"f35b1e576e30\",\n" +
|
||||||
|
" \"stageName\": \"并行阶段-2-1\",\n" +
|
||||||
|
" \"createTime\": \"2025-03-10 14:51:43\",\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"stageSort\": 1,\n" +
|
||||||
|
" \"parentId\": \"3b1a5fdd9b6c\",\n" +
|
||||||
|
" \"code\": false,\n" +
|
||||||
|
" \"taskValues\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"taskId\": \"21a965370481\",\n" +
|
||||||
|
" \"createTime\": \"2025-03-10 14:51:43\",\n" +
|
||||||
|
" \"taskType\": \"maven\",\n" +
|
||||||
|
" \"taskSort\": 1,\n" +
|
||||||
|
" \"taskName\": \"Maven构建\",\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"f35b1e576e30\",\n" +
|
||||||
|
" \"task\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"stageList\": null,\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"871c1b69efe0\",\n" +
|
||||||
|
" \"stageName\": \"阶段-3\",\n" +
|
||||||
|
" \"createTime\": \"2025-03-10 14:52:27\",\n" +
|
||||||
|
" \"pipelineId\": \"a69119cfbbde\",\n" +
|
||||||
|
" \"stageSort\": 3,\n" +
|
||||||
|
" \"parentId\": null,\n" +
|
||||||
|
" \"code\": false,\n" +
|
||||||
|
" \"taskValues\": null,\n" +
|
||||||
|
" \"stageList\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"63676c8428e6\",\n" +
|
||||||
|
" \"stageName\": \"并行阶段-3-1\",\n" +
|
||||||
|
" \"createTime\": \"2025-03-10 14:52:27\",\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"stageSort\": 1,\n" +
|
||||||
|
" \"parentId\": \"871c1b69efe0\",\n" +
|
||||||
|
" \"code\": false,\n" +
|
||||||
|
" \"taskValues\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"taskId\": \"b5eaf0832ff1\",\n" +
|
||||||
|
" \"createTime\": \"2025-03-10 14:52:27\",\n" +
|
||||||
|
" \"taskType\": \"liunx\",\n" +
|
||||||
|
" \"taskSort\": 1,\n" +
|
||||||
|
" \"taskName\": \"主机部署\",\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"63676c8428e6\",\n" +
|
||||||
|
" \"task\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"taskId\": \"cf756d646758\",\n" +
|
||||||
|
" \"createTime\": \"2025-05-10 14:17:52\",\n" +
|
||||||
|
" \"taskType\": \"script\",\n" +
|
||||||
|
" \"taskSort\": 2,\n" +
|
||||||
|
" \"taskName\": \"执行脚本\",\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"63676c8428e6\",\n" +
|
||||||
|
" \"task\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"stageList\": null,\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"stageId\": \"e9e4ac139f7b\",\n" +
|
||||||
|
" \"stageName\": \"并行阶段-3-2\",\n" +
|
||||||
|
" \"createTime\": \"2025-04-30 20:29:23\",\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"stageSort\": 2,\n" +
|
||||||
|
" \"parentId\": \"871c1b69efe0\",\n" +
|
||||||
|
" \"code\": false,\n" +
|
||||||
|
" \"taskValues\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"taskId\": \"e46283a4b6d1\",\n" +
|
||||||
|
" \"createTime\": \"2025-04-30 20:29:23\",\n" +
|
||||||
|
" \"taskType\": \"script\",\n" +
|
||||||
|
" \"taskSort\": 1,\n" +
|
||||||
|
" \"taskName\": \"执行脚本\",\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"e9e4ac139f7b\",\n" +
|
||||||
|
" \"task\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"taskId\": \"40740f834ce8\",\n" +
|
||||||
|
" \"createTime\": \"2025-05-10 14:17:17\",\n" +
|
||||||
|
" \"taskType\": \"script\",\n" +
|
||||||
|
" \"taskSort\": 2,\n" +
|
||||||
|
" \"taskName\": \"执行脚本\",\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"e9e4ac139f7b\",\n" +
|
||||||
|
" \"task\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"stageList\": null,\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"taskType\": null,\n" +
|
||||||
|
" \"taskId\": null,\n" +
|
||||||
|
" \"values\": null,\n" +
|
||||||
|
" \"taskSort\": 0,\n" +
|
||||||
|
" \"parallelName\": null,\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
"]";
|
||||||
|
JSONArray objects = JSON.parseArray(taskStr);
|
||||||
|
List<StageResp> tasks = new ArrayList<>(objects.size());
|
||||||
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
|
StageResp object = objects.getObject(i, StageResp.class);
|
||||||
|
tasks.add(object);
|
||||||
|
}
|
||||||
|
return CommonResult.success(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @pi.name:更新流水线阶段任务
|
||||||
|
// * @pi.path:/stage/createStage
|
||||||
|
// * @pi.methodType:post
|
||||||
|
// * @pi.request-type:json
|
||||||
|
// * @pi.param: model=stage
|
||||||
|
// */
|
||||||
|
// @RequestMapping(path="/updateStage",method = RequestMethod.POST)
|
||||||
|
// public Result<Void> updateStageTask(@RequestBody @Valid @NotNull Stage stage){
|
||||||
|
// stageService.updateStagesTask(stage);
|
||||||
|
// return Result.ok();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @pi.name:更新流水线阶段名称
|
||||||
|
// * @pi.path:/stage/updateStageName
|
||||||
|
// * @pi.methodType:post
|
||||||
|
// * @pi.request-type:json
|
||||||
|
// * @pi.param: model=stage
|
||||||
|
// */
|
||||||
|
// @RequestMapping(path="/updateStageName",method = RequestMethod.POST)
|
||||||
|
// public Result<Void> updateTasksStage(@RequestBody @Valid @NotNull Stage stage){
|
||||||
|
// stageService.updateStageName(stage);
|
||||||
|
// return Result.ok();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @pi.name:删除流水线阶段及任务
|
||||||
|
// * @pi.path:/stage/deleteStage
|
||||||
|
// * @pi.methodType:post
|
||||||
|
// * @pi.request-type: formdata
|
||||||
|
// * @pi.param: name=taskId;dataType=string;value=taskId;
|
||||||
|
// */
|
||||||
|
// @RequestMapping(path="/deleteStage",method = RequestMethod.POST)
|
||||||
|
// public Result<Void> deleteTasksOrStage(@NotNull String taskId){
|
||||||
|
// stageService.deleteStagesOrTask(taskId);
|
||||||
|
// return Result.ok();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @pi.name:效验流水线各个配置阶段完整性
|
||||||
|
// * @pi.path:/stage/validStagesMustField
|
||||||
|
// * @pi.methodType:post
|
||||||
|
// * @pi.request-type: formdata
|
||||||
|
// * @pi.param: name=pipelineId;dataType=string;value=流水线Id;
|
||||||
|
// */
|
||||||
|
// @RequestMapping(path="/validStagesMustField",method = RequestMethod.POST)
|
||||||
|
// public Result<List<String>> validStagesMustField(@NotNull String pipelineId){
|
||||||
|
// List<String> list = stageService.validStagesMustField(pipelineId);
|
||||||
|
// return Result.ok(list);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
|||||||
|
package cd.casic.server.controller;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.resp.task.TasksResp;
|
||||||
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
public class TasksController {
|
||||||
|
/**
|
||||||
|
* @pi.name:查询任务及任务详情
|
||||||
|
* @pi.path:/tasks/findOneTasksOrTask
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type: formdata
|
||||||
|
* @pi.param: name=taskId;dataType=string;value=taskId;
|
||||||
|
*/
|
||||||
|
@RequestMapping(path="/findOneTasksOrTask",method = RequestMethod.POST)
|
||||||
|
public CommonResult<TasksResp> findOneTasksOrTask(@NotNull String taskId){
|
||||||
|
// Tasks tasksOrTask = tasksService.findOneTasksOrTask(taskId);
|
||||||
|
String tasksStr = "{\n" +
|
||||||
|
" \"taskId\": \"842b38734ded\",\n" +
|
||||||
|
" \"createTime\": \"2025-05-10 16:58:55\",\n" +
|
||||||
|
" \"taskType\": \"maventest\",\n" +
|
||||||
|
" \"taskSort\": 1,\n" +
|
||||||
|
" \"taskName\": \"Maven单元测试\",\n" +
|
||||||
|
" \"values\": {\n" +
|
||||||
|
" \"taskId\": \"842b38734ded\",\n" +
|
||||||
|
" \"testOrder\": \"mvn test\",\n" +
|
||||||
|
" \"address\": \"${DEFAULT_CODE_ADDRESS}\",\n" +
|
||||||
|
" \"testSpace\": null,\n" +
|
||||||
|
" \"testPlan\": null,\n" +
|
||||||
|
" \"apiEnv\": null,\n" +
|
||||||
|
" \"appEnv\": null,\n" +
|
||||||
|
" \"webEnv\": null,\n" +
|
||||||
|
" \"authId\": null,\n" +
|
||||||
|
" \"auth\": null,\n" +
|
||||||
|
" \"type\": null,\n" +
|
||||||
|
" \"sort\": 0,\n" +
|
||||||
|
" \"instanceId\": null,\n" +
|
||||||
|
" \"toolJdk\": null,\n" +
|
||||||
|
" \"toolMaven\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"postprocessId\": null,\n" +
|
||||||
|
" \"stageId\": \"5656dfdfe90d\",\n" +
|
||||||
|
" \"task\": {\n" +
|
||||||
|
" \"taskId\": \"842b38734ded\",\n" +
|
||||||
|
" \"testOrder\": \"mvn test\",\n" +
|
||||||
|
" \"address\": \"${DEFAULT_CODE_ADDRESS}\",\n" +
|
||||||
|
" \"testSpace\": null,\n" +
|
||||||
|
" \"testPlan\": null,\n" +
|
||||||
|
" \"apiEnv\": null,\n" +
|
||||||
|
" \"appEnv\": null,\n" +
|
||||||
|
" \"webEnv\": null,\n" +
|
||||||
|
" \"authId\": null,\n" +
|
||||||
|
" \"auth\": null,\n" +
|
||||||
|
" \"type\": null,\n" +
|
||||||
|
" \"sort\": 0,\n" +
|
||||||
|
" \"instanceId\": null,\n" +
|
||||||
|
" \"toolJdk\": null,\n" +
|
||||||
|
" \"toolMaven\": null\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"instanceId\": null\n" +
|
||||||
|
"}";
|
||||||
|
TasksResp tasksResp = JSON.parseObject(tasksStr, TasksResp.class);
|
||||||
|
return CommonResult.success(tasksResp);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package cd.casic.server.controller;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.req.trigger.TriggerQueryReq;
|
||||||
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
/**
|
||||||
|
* @pi.protocol: http
|
||||||
|
* @pi.groupName: 流水线触发器控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/trigger")
|
||||||
|
public class TriggerController {
|
||||||
|
/**
|
||||||
|
* @pi.name:条件查询流水线触发器信息
|
||||||
|
* @pi.path:/trigger/findAllTrigger
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type:json
|
||||||
|
* @pi.param: model=triggerQuery
|
||||||
|
*/
|
||||||
|
@PostMapping(path="/findAllTrigger")
|
||||||
|
public CommonResult<List<Object>> findAllTrigger(@RequestBody @Valid @NotNull TriggerQueryReq triggerQuery) {
|
||||||
|
// List<Object> list = triggerServer.findAllTrigger(triggerQuery);
|
||||||
|
String triggers = "[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"timeId\": \"3e0ef2372dfc\",\n" +
|
||||||
|
" \"taskType\": 1,\n" +
|
||||||
|
" \"date\": 1,\n" +
|
||||||
|
" \"time\": \"16:00\",\n" +
|
||||||
|
" \"triggerId\": \"9f2ca05e88d4\",\n" +
|
||||||
|
" \"cron\": \"00 00 16 12 5 ? 2025\",\n" +
|
||||||
|
" \"weekTime\": \"2025-5-12 16:00:00\",\n" +
|
||||||
|
" \"execTime\": \"周一 | 周二 | 周三 | 16:00\",\n" +
|
||||||
|
" \"timeList\": [\n" +
|
||||||
|
" 1,\n" +
|
||||||
|
" 2,\n" +
|
||||||
|
" 3\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"dayTime\": null,\n" +
|
||||||
|
" \"type\": 81,\n" +
|
||||||
|
" \"name\": null,\n" +
|
||||||
|
" \"state\": \"1\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"]";
|
||||||
|
JSONArray objects = JSON.parseArray(triggers);
|
||||||
|
return CommonResult.success(objects);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package cd.casic.server.controller;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.req.variable.VariableReq;
|
||||||
|
import cd.casic.ci.common.pipeline.resp.variable.VariableResp;
|
||||||
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.protocol: http
|
||||||
|
* @pi.groupName: 流水线变量控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pipelineVariable")
|
||||||
|
public class VariableController {
|
||||||
|
/**
|
||||||
|
* @pi.name:创建流水线变量
|
||||||
|
* @pi.path:/pipelineVariable/createVariable
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type:json
|
||||||
|
* @pi.param: model=variable
|
||||||
|
*/
|
||||||
|
@RequestMapping(path="/createVariable",method = RequestMethod.POST)
|
||||||
|
public CommonResult<String> createVariable(@RequestBody @NotNull @Valid VariableReq variable){
|
||||||
|
String variableId = "";
|
||||||
|
// String variableId = variableServer.createVariable(variable);
|
||||||
|
return CommonResult.success(variableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.name:删除流水线变量
|
||||||
|
* @pi.path:/pipelineVariable/deleteVariable
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type: formdata
|
||||||
|
* @pi.param: name=varId;dataType=string;value=varId;
|
||||||
|
*/
|
||||||
|
@RequestMapping(path="/deleteVariable",method = RequestMethod.POST)
|
||||||
|
public CommonResult<String> deleteVariable( @NotNull String varId){
|
||||||
|
// variableServer.deleteVariable(varId);
|
||||||
|
return CommonResult.success("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.name:更新流水线变量
|
||||||
|
* @pi.path:/pipelineVariable/createVariable
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type:json
|
||||||
|
* @pi.param: model=variable
|
||||||
|
*/
|
||||||
|
@RequestMapping(path="/updateVariable",method = RequestMethod.POST)
|
||||||
|
public CommonResult<String> updateVariable(@RequestBody @NotNull @Valid VariableReq variable){
|
||||||
|
// variableServer.updateVariable(variable);
|
||||||
|
return CommonResult.success("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pi.name:查询流水线任务变量
|
||||||
|
* @pi.path:/pipelineVariable/findAllVariable
|
||||||
|
* @pi.methodType:post
|
||||||
|
* @pi.request-type: formdata
|
||||||
|
* @pi.param: name=taskId;dataType=string;value=任务id;
|
||||||
|
*/
|
||||||
|
@RequestMapping(path="/findAllVariable",method = RequestMethod.POST)
|
||||||
|
public CommonResult<List<VariableResp>> findAllVariable(@NotNull String taskId){
|
||||||
|
// List<VariableResp> allVariable = variableServer.findAllVariable(taskId);
|
||||||
|
String varListStr = "[\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"varId\": \"04b629ce9234\",\n" +
|
||||||
|
" \"createTime\": \"2025-05-10 14:25:24\",\n" +
|
||||||
|
" \"varType\": \"str\",\n" +
|
||||||
|
" \"type\": 1,\n" +
|
||||||
|
" \"taskId\": \"a69119cfbbde\",\n" +
|
||||||
|
" \"pipelineId\": null,\n" +
|
||||||
|
" \"varKey\": \"testVal\",\n" +
|
||||||
|
" \"varValue\": \"123\",\n" +
|
||||||
|
" \"varValues\": null,\n" +
|
||||||
|
" \"valueList\": null\n" +
|
||||||
|
" }\n" +
|
||||||
|
"]";
|
||||||
|
JSONArray objects = JSON.parseArray(varListStr);
|
||||||
|
List<VariableResp> allVariable = new ArrayList<>(objects.size());
|
||||||
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
|
VariableResp object = objects.getObject(i, VariableResp.class);
|
||||||
|
allVariable.add(object);
|
||||||
|
}
|
||||||
|
return CommonResult.success(allVariable);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user