增加生成后端服务代码。
This commit is contained in:
parent
5d375b7783
commit
9b7d7a23a3
@ -4,104 +4,20 @@ import com.qqchen.deploy.backend.workflow.annotation.CodeEditorConfig;
|
|||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSource;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSource;
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSourceParam;
|
import com.qqchen.deploy.backend.workflow.annotation.SchemaPropertyDataSourceParam;
|
||||||
|
import com.qqchen.deploy.backend.workflow.dto.definition.node.fromVariables.DeployNodeFormVariables;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jenkins构建变量
|
* Jenkins构建变量
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class JenkinsBaseBuildVariables {
|
public class JenkinsBaseBuildVariables extends DeployNodeFormVariables {
|
||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "绑定三方Jenkins系统",
|
title = "",
|
||||||
description = "请选择三方Jenkins系统",
|
description = "审批人填写的意见",
|
||||||
required = true,
|
order = 0
|
||||||
dataSource = @SchemaPropertyDataSource(
|
|
||||||
type = "api",
|
|
||||||
url = "/api/v1/external-system/list?type=JENKINS",
|
|
||||||
valueField = "id",
|
|
||||||
labelField = "name"
|
|
||||||
),
|
|
||||||
order = 1
|
|
||||||
)
|
)
|
||||||
private String externalSystemId;
|
private String taskId;
|
||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "绑定Jenkins视图",
|
|
||||||
description = "Jenkins视图",
|
|
||||||
required = true,
|
|
||||||
dataSource = @SchemaPropertyDataSource(
|
|
||||||
type = "api",
|
|
||||||
url = "/api/v1/jenkins-view/list",
|
|
||||||
valueField = "id",
|
|
||||||
labelField = "viewName",
|
|
||||||
dependsOn = {"externalSystemId"},
|
|
||||||
params = {
|
|
||||||
@SchemaPropertyDataSourceParam(name = "externalSystemId", value = "${externalSystemId}")
|
|
||||||
}
|
|
||||||
),
|
|
||||||
order = 2
|
|
||||||
)
|
|
||||||
private String viewId;
|
|
||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "绑定Jenkins任务",
|
|
||||||
description = "Jenkins任务",
|
|
||||||
required = true,
|
|
||||||
dataSource = @SchemaPropertyDataSource(
|
|
||||||
type = "api",
|
|
||||||
url = "/api/v1/jenkins-job/list",
|
|
||||||
valueField = "id",
|
|
||||||
labelField = "jobName",
|
|
||||||
dependsOn = {"externalSystemId", "viewId"},
|
|
||||||
params = {
|
|
||||||
@SchemaPropertyDataSourceParam(name = "externalSystemId", value = "${externalSystemId}"),
|
|
||||||
@SchemaPropertyDataSourceParam(name = "viewId", value = "${viewId}")
|
|
||||||
}
|
|
||||||
),
|
|
||||||
order = 3
|
|
||||||
)
|
|
||||||
private String jobId;
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "分支名称",
|
|
||||||
description = "GIT分支名称",
|
|
||||||
required = true,
|
|
||||||
order = 4
|
|
||||||
)
|
|
||||||
private String branch;
|
|
||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "构建产物路径",
|
|
||||||
description = "构建产物路径",
|
|
||||||
order = 5
|
|
||||||
)
|
|
||||||
private String artifactPath;
|
|
||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "Pipeline script",
|
|
||||||
description = "流水线脚本",
|
|
||||||
required = true,
|
|
||||||
format = "monaco-editor", // 使用 Monaco Editor
|
|
||||||
defaultValue = "#!/bin/bash\n\necho \"Hello World\"",
|
|
||||||
codeEditor = @CodeEditorConfig(
|
|
||||||
language = "shell",
|
|
||||||
theme = "vs-dark",
|
|
||||||
minimap = false,
|
|
||||||
lineNumbers = true,
|
|
||||||
wordWrap = true,
|
|
||||||
fontSize = 14,
|
|
||||||
tabSize = 2,
|
|
||||||
autoComplete = true,
|
|
||||||
folding = true
|
|
||||||
),
|
|
||||||
order = 6
|
|
||||||
)
|
|
||||||
private String script;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.qqchen.deploy.backend.deploy.dto.variables;
|
package com.qqchen.deploy.backend.deploy.dto.variables;
|
||||||
|
|
||||||
|
import com.qqchen.deploy.backend.workflow.dto.definition.node.fromVariables.DeployNodeFormVariables;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
@ -7,8 +8,7 @@ import lombok.Data;
|
|||||||
* Jenkins构建变量
|
* Jenkins构建变量
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class JenkinsJavaBuildVariables extends JenkinsBaseBuildVariables {
|
public class JenkinsJavaBuildVariables extends DeployNodeFormVariables {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,19 +0,0 @@
|
|||||||
package com.qqchen.deploy.backend.workflow.dto.definition.node.fromVariables;
|
|
||||||
|
|
||||||
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每次使用基本都是会变的变量
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BaseDeployNodeFormVariables {
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "禅道ID",
|
|
||||||
description = "真实的禅道ID",
|
|
||||||
required = true
|
|
||||||
)
|
|
||||||
private String zentaoId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -9,6 +9,4 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class BaseNodeFormVariables {
|
public class BaseNodeFormVariables {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
public class ScriptNodeFormVariables {
|
||||||
public class ScriptNodeFormVariables extends BaseDeployNodeFormVariables {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,16 +42,16 @@ public class GlobalExecutionListener implements ExecutionListener {
|
|||||||
WorkflowNodeInstanceStatusEnums status = null;
|
WorkflowNodeInstanceStatusEnums status = null;
|
||||||
LocalDateTime startTime = null;
|
LocalDateTime startTime = null;
|
||||||
LocalDateTime endTime = null;
|
LocalDateTime endTime = null;
|
||||||
|
String nodeExecutionStatus = Optional.ofNullable(execution.getVariables())
|
||||||
|
.map(vars -> vars.get(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME))
|
||||||
|
.map(Object::toString)
|
||||||
|
.orElse(null);
|
||||||
switch (eventName) {
|
switch (eventName) {
|
||||||
case ExecutionListener.EVENTNAME_START:
|
case ExecutionListener.EVENTNAME_START:
|
||||||
status = WorkflowNodeInstanceStatusEnums.RUNNING;
|
status = WorkflowNodeInstanceStatusEnums.RUNNING;
|
||||||
startTime = now;
|
startTime = now;
|
||||||
break;
|
break;
|
||||||
case ExecutionListener.EVENTNAME_END:
|
case ExecutionListener.EVENTNAME_END:
|
||||||
String nodeExecutionStatus = Optional.ofNullable(execution.getVariables())
|
|
||||||
.map(vars -> vars.get(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME))
|
|
||||||
.map(Object::toString)
|
|
||||||
.orElse(null);
|
|
||||||
if (StringUtils.isEmpty(nodeExecutionStatus)) {
|
if (StringUtils.isEmpty(nodeExecutionStatus)) {
|
||||||
status = WorkflowNodeInstanceStatusEnums.COMPLETED;
|
status = WorkflowNodeInstanceStatusEnums.COMPLETED;
|
||||||
} else {
|
} else {
|
||||||
@ -77,5 +77,8 @@ public class GlobalExecutionListener implements ExecutionListener {
|
|||||||
.startTime(startTime)
|
.startTime(startTime)
|
||||||
.endTime(endTime)
|
.endTime(endTime)
|
||||||
.build());
|
.build());
|
||||||
|
if (StringUtils.isNotEmpty(nodeExecutionStatus)) {
|
||||||
|
execution.removeVariable(WORKFLOW_PREVIOUS_NODE_EXECUTION_STATUS_VARIABLE_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ public class BpmnConverter {
|
|||||||
*/
|
*/
|
||||||
private void configureServiceTask(ServiceTask serviceTask, WorkflowDefinitionGraphNode node, Process process, Map<String, List<ExtensionElement>> extensionElements) {
|
private void configureServiceTask(ServiceTask serviceTask, WorkflowDefinitionGraphNode node, Process process, Map<String, List<ExtensionElement>> extensionElements) {
|
||||||
if (node.getPanelVariables() != null && node.getPanelVariables().has("delegate")) {
|
if (node.getPanelVariables() != null && node.getPanelVariables().has("delegate")) {
|
||||||
String delegate = node.getLocalVariables().get("delegate").asText();
|
String delegate = node.getPanelVariables().get("delegate").asText();
|
||||||
serviceTask.setImplementationType("delegateExpression");
|
serviceTask.setImplementationType("delegateExpression");
|
||||||
serviceTask.setImplementation(delegate);
|
serviceTask.setImplementation(delegate);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user