142 lines
4.3 KiB
TypeScript
142 lines
4.3 KiB
TypeScript
import {ConfigurableNodeDefinition, NodeType, NodeCategory} from './types';
|
||
import {DataSourceType} from '../utils/dataSourceLoader';
|
||
|
||
/**
|
||
* Jenkins构建节点定义(纯配置)
|
||
* 使用 BaseNode 组件渲染,无需自定义渲染代码
|
||
*/
|
||
export const JenkinsBuildNodeDefinition: ConfigurableNodeDefinition = {
|
||
nodeCode: "JENKINS_BUILD",
|
||
nodeName: "Jenkins构建",
|
||
nodeType: NodeType.JENKINS_BUILD,
|
||
category: NodeCategory.TASK,
|
||
description: "通过Jenkins执行构建任务",
|
||
|
||
// 渲染配置(配置驱动)
|
||
renderConfig: {
|
||
shape: 'rounded-rect',
|
||
size: {width: 140, height: 48},
|
||
icon: {
|
||
type: 'emoji',
|
||
content: '🔨',
|
||
size: 32
|
||
},
|
||
theme: {
|
||
primary: '#f59e0b',
|
||
secondary: '#d97706',
|
||
selectedBorder: '#3b82f6',
|
||
hoverBorder: '#f59e0b',
|
||
gradient: ['#ffffff', '#fef3c7']
|
||
},
|
||
handles: {
|
||
input: true,
|
||
output: true
|
||
},
|
||
features: {
|
||
showBadge: true,
|
||
showHoverMenu: true
|
||
}
|
||
},
|
||
|
||
// 基本配置Schema
|
||
configSchema: {
|
||
type: "object",
|
||
title: "基本配置",
|
||
description: "节点的基本信息和Jenkins构建配置参数",
|
||
properties: {
|
||
nodeName: {
|
||
type: "string",
|
||
title: "节点名称",
|
||
description: "节点在流程图中显示的名称",
|
||
default: "Jenkins构建"
|
||
},
|
||
nodeCode: {
|
||
type: "string",
|
||
title: "节点编码",
|
||
description: "节点的唯一标识符",
|
||
default: "JENKINS_BUILD"
|
||
},
|
||
description: {
|
||
type: "string",
|
||
title: "节点描述",
|
||
description: "节点的详细说明",
|
||
default: "通过Jenkins执行构建任务"
|
||
}
|
||
},
|
||
required: ["nodeName", "nodeCode", "jenkinsServerId"]
|
||
},
|
||
inputMappingSchema: {
|
||
type: "object",
|
||
title: "输入",
|
||
description: "当前节点所需数据配置",
|
||
properties: {
|
||
jenkinsServerId: {
|
||
type: "number",
|
||
title: "服务器",
|
||
description: "选择要使用的服务器",
|
||
'x-dataSource': DataSourceType.JENKINS_SERVERS
|
||
},
|
||
project: {
|
||
type: "string",
|
||
title: "项目",
|
||
description: "要触发构建的项目",
|
||
default: ""
|
||
},
|
||
},
|
||
required: ["jenkinsServerId"]
|
||
},
|
||
outputs: [
|
||
{
|
||
name: "buildNumber",
|
||
title: "构建编号",
|
||
type: "number",
|
||
description: "Jenkins构建的唯一编号",
|
||
example: 123,
|
||
required: true
|
||
},
|
||
{
|
||
name: "buildStatus",
|
||
title: "构建状态",
|
||
type: "string",
|
||
enum: ["SUCCESS", "FAILURE", "UNSTABLE", "ABORTED"],
|
||
description: "构建执行的结果状态",
|
||
example: "SUCCESS",
|
||
required: true
|
||
},
|
||
{
|
||
name: "buildUrl",
|
||
title: "构建URL",
|
||
type: "string",
|
||
description: "Jenkins构建页面的访问地址",
|
||
example: "http://jenkins.example.com/job/app/123/",
|
||
required: true
|
||
},
|
||
{
|
||
name: "artifactUrl",
|
||
title: "构建产物地址",
|
||
type: "string",
|
||
description: "构建生成的jar/war包下载地址",
|
||
example: "http://jenkins.example.com/job/app/123/artifact/target/app-1.0.0.jar",
|
||
required: false
|
||
},
|
||
{
|
||
name: "gitCommitId",
|
||
title: "Git提交ID",
|
||
type: "string",
|
||
description: "本次构建使用的Git提交哈希值",
|
||
example: "a3f5e8d2c4b1a5e9f2d3e7b8c9d1a2f3e4b5c6d7",
|
||
required: true
|
||
},
|
||
{
|
||
name: "buildDuration",
|
||
title: "构建时长",
|
||
type: "number",
|
||
description: "构建执行的时长(秒)",
|
||
example: 120,
|
||
required: true
|
||
}
|
||
]
|
||
};
|
||
|
||
// ✅ 不再需要单独的渲染组件,使用 BaseNode 即可
|