* panelVariables: 节点配置,一次配置长期有效
* localVariables: 运行时变量,每次执行都会变化
- * fromVariables: 表单输入,每次执行需要用户填写
*/
@Slf4j
public abstract class BaseNodeDelegate implements JavaDelegate {
@@ -39,8 +39,6 @@ public abstract class BaseNodeDelegate
implements JavaDelegate {
// 字段注入,由Flowable自动设置
protected Expression panelVariables;
- protected Expression localVariables;
-
@Override
public void execute(DelegateExecution execution) {
try {
@@ -55,13 +53,7 @@ public abstract class BaseNodeDelegate
implements JavaDelegate {
}
// 获取并转换Local变量
- L localVars = null;
- if (localVariables != null) {
- String localVarsJson = localVariables.getValue(execution).toString();
- JsonNode localVarsNode = objectMapper.readTree(localVarsJson);
- localVars = objectMapper.treeToValue(localVarsNode, getLocalVariablesClass());
- }
-
+ L localVars = objectMapper.convertValue(execution.getVariables(), getLocalVariablesClass());
// 执行具体的任务逻辑
executeInternal(execution, panelVars, localVars);
diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/delegate/DeployNodeDelegate.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/delegate/DeployNodeDelegate.java
index 04a2382d..3ca90dfe 100644
--- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/delegate/DeployNodeDelegate.java
+++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/delegate/DeployNodeDelegate.java
@@ -1,8 +1,13 @@
package com.qqchen.deploy.backend.workflow.delegate;
+import com.qqchen.deploy.backend.deploy.entity.ExternalSystem;
+import com.qqchen.deploy.backend.deploy.entity.JenkinsJob;
import com.qqchen.deploy.backend.deploy.enums.JenkinsBuildStatus;
+import com.qqchen.deploy.backend.deploy.integration.IExternalSystemIntegration;
import com.qqchen.deploy.backend.deploy.integration.IJenkinsServiceIntegration;
import com.qqchen.deploy.backend.deploy.integration.response.JenkinsQueueBuildInfoResponse;
+import com.qqchen.deploy.backend.deploy.repository.IExternalSystemRepository;
+import com.qqchen.deploy.backend.deploy.repository.IJenkinsJobRepository;
import com.qqchen.deploy.backend.workflow.constants.WorkFlowConstants;
import com.qqchen.deploy.backend.workflow.dto.definition.node.localVariables.DeployNodeLocalVariables;
import com.qqchen.deploy.backend.workflow.dto.definition.node.panelVariables.DeployNodePanelVariables;
@@ -36,6 +41,12 @@ public class DeployNodeDelegate extends BaseNodeDelegate getPanelVariablesClass() {
return DeployNodePanelVariables.class;
@@ -48,10 +59,12 @@ public class DeployNodeDelegate extends BaseNodeDelegate new RuntimeException("ExternalSystem not found!!!"));
+ JenkinsJob jenkinsJob = jenkinsJobRepository.findById(localVariables.getJobId()).orElseThrow(() -> new RuntimeException("Jenkins job not found!!!"));
+ String queueId = jenkinsServiceIntegration.buildWithParameters(externalSystem, jenkinsJob.getJobName());
JenkinsQueueBuildInfoResponse buildInfo = waitForBuildToStart(queueId);
// 3. 轮询构建状态
- pollBuildStatus("scp-meta", buildInfo.getBuildNumber());
+ pollBuildStatus(externalSystem, jenkinsJob.getJobName(), buildInfo.getBuildNumber());
}
private JenkinsQueueBuildInfoResponse waitForBuildToStart(String queueId) {
@@ -77,7 +90,7 @@ public class DeployNodeDelegate extends BaseNodeDelegate variables;
}
diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/node/localVariables/DeployNodeLocalVariables.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/node/localVariables/DeployNodeLocalVariables.java
index 5dcbefd2..9fd7bdb9 100644
--- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/node/localVariables/DeployNodeLocalVariables.java
+++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/dto/definition/node/localVariables/DeployNodeLocalVariables.java
@@ -14,7 +14,7 @@ public class DeployNodeLocalVariables extends BaseNodeLocalVariables {
description = "三方Jenkins系统",
required = true
)
- private String externalSystemId;
+ private Long externalSystemId;
@SchemaProperty(
@@ -23,7 +23,7 @@ public class DeployNodeLocalVariables extends BaseNodeLocalVariables {
required = true,
order = 3
)
- private String viewId;
+ private Long viewId;
@SchemaProperty(
@@ -32,6 +32,6 @@ public class DeployNodeLocalVariables extends BaseNodeLocalVariables {
required = true,
order = 4
)
- private String jobId;
+ private Long jobId;
}
diff --git a/backend/src/main/java/com/qqchen/deploy/backend/workflow/service/impl/WorkflowInstanceServiceImpl.java b/backend/src/main/java/com/qqchen/deploy/backend/workflow/service/impl/WorkflowInstanceServiceImpl.java
index f2bf39b7..eba63071 100644
--- a/backend/src/main/java/com/qqchen/deploy/backend/workflow/service/impl/WorkflowInstanceServiceImpl.java
+++ b/backend/src/main/java/com/qqchen/deploy/backend/workflow/service/impl/WorkflowInstanceServiceImpl.java
@@ -178,7 +178,9 @@ public class WorkflowInstanceServiceImpl extends BaseServiceImpl new RuntimeException("Workflow definition process key not found: " + request.getProcessKey()));
ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder()
.processDefinitionKey(request.getProcessKey())
+ .variables(request.getVariables())
.businessKey(request.getBusinessKey())
+ .variables(request.getVariables())
.startAsync(); // 异步启动,会自动执行 shell 任务
// .start();
return createWorkflowInstance(workflowDefinition.getId(), request.getBusinessKey(), processInstance);
diff --git a/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql b/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql
index 2b2a1469..29b71892 100644
--- a/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql
+++ b/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql
@@ -647,3 +647,26 @@ CREATE TABLE deploy_project_group_environment
REFERENCES deploy_environment (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='项目组环境关联表';
+
+CREATE TABLE deploy_log
+(
+ -- 基础字段
+ id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID',
+ -- 业务字段
+ workflow_instance_id BIGINT NULL COMMENT '工作流实例ID',
+ environment_id BIGINT NOT NULL COMMENT '环境ID',
+ application_id BIGINT NOT NULL COMMENT '应用ID',
+ deploy_version VARCHAR(100) NOT NULL COMMENT '部署版本号',
+ form_variables TEXT NULL COMMENT '部署参数(JSON)',
+ deploy_variables TEXT NULL COMMENT '部署参数(JSON)',
+
+ create_by VARCHAR(100) NULL COMMENT '创建人',
+ create_time DATETIME(6) NULL COMMENT '创建时间',
+ update_by VARCHAR(100) NULL COMMENT '更新人',
+ update_time DATETIME(6) NULL COMMENT '更新时间',
+ version INT NOT NULL DEFAULT 1 COMMENT '版本号',
+ deleted BIT NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除'
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='部署日志表';
+