1
This commit is contained in:
parent
7464b0a6e9
commit
abe1153d16
@ -0,0 +1,271 @@
|
|||||||
|
import { ConfigurableNodeDefinition, NodeType, NodeCategory } from '../types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jenkins构建节点定义
|
||||||
|
* 可配置节点,支持配置、输入映射、输出映射
|
||||||
|
*/
|
||||||
|
export const JenkinsBuildNode: ConfigurableNodeDefinition = {
|
||||||
|
nodeCode: "JENKINS_BUILD",
|
||||||
|
nodeName: "Jenkins构建",
|
||||||
|
nodeType: NodeType.JENKINS_BUILD,
|
||||||
|
category: NodeCategory.TASK,
|
||||||
|
description: "通过Jenkins执行构建任务",
|
||||||
|
|
||||||
|
// UI 配置 - 节点在画布上的显示样式
|
||||||
|
uiConfig: {
|
||||||
|
shape: 'rect',
|
||||||
|
size: {
|
||||||
|
width: 160,
|
||||||
|
height: 80
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fill: '#52c41a',
|
||||||
|
stroke: '#389e08',
|
||||||
|
strokeWidth: 2,
|
||||||
|
icon: 'jenkins',
|
||||||
|
iconColor: '#fff'
|
||||||
|
},
|
||||||
|
ports: {
|
||||||
|
groups: {
|
||||||
|
// 输入端口
|
||||||
|
in: {
|
||||||
|
position: 'left',
|
||||||
|
attrs: {
|
||||||
|
circle: {
|
||||||
|
r: 4,
|
||||||
|
fill: '#fff',
|
||||||
|
stroke: '#52c41a'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 输出端口
|
||||||
|
out: {
|
||||||
|
position: 'right',
|
||||||
|
attrs: {
|
||||||
|
circle: {
|
||||||
|
r: 4,
|
||||||
|
fill: '#fff',
|
||||||
|
stroke: '#52c41a'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 基本配置Schema - 设计时用于生成表单,保存时转为key/value(包含基本信息和Jenkins配置)
|
||||||
|
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执行构建任务"
|
||||||
|
},
|
||||||
|
jenkinsUrl: {
|
||||||
|
type: "string",
|
||||||
|
title: "Jenkins服务器地址",
|
||||||
|
description: "Jenkins服务器的完整URL地址",
|
||||||
|
default: "http://jenkins.example.com:8080",
|
||||||
|
format: "uri"
|
||||||
|
},
|
||||||
|
jobName: {
|
||||||
|
type: "string",
|
||||||
|
title: "Job名称",
|
||||||
|
description: "要执行的Jenkins Job名称",
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: "string",
|
||||||
|
title: "用户名",
|
||||||
|
description: "Jenkins认证用户名",
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
apiToken: {
|
||||||
|
type: "string",
|
||||||
|
title: "API Token",
|
||||||
|
description: "Jenkins API Token或密码",
|
||||||
|
default: "",
|
||||||
|
format: "password"
|
||||||
|
},
|
||||||
|
timeout: {
|
||||||
|
type: "number",
|
||||||
|
title: "超时时间(秒)",
|
||||||
|
description: "构建超时时间",
|
||||||
|
default: 600,
|
||||||
|
minimum: 60,
|
||||||
|
maximum: 7200
|
||||||
|
},
|
||||||
|
waitForCompletion: {
|
||||||
|
type: "boolean",
|
||||||
|
title: "等待构建完成",
|
||||||
|
description: "是否等待Jenkins构建完成",
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
retryCount: {
|
||||||
|
type: "number",
|
||||||
|
title: "重试次数",
|
||||||
|
description: "构建失败时的重试次数",
|
||||||
|
default: 1,
|
||||||
|
minimum: 0,
|
||||||
|
maximum: 5
|
||||||
|
},
|
||||||
|
branchName: {
|
||||||
|
type: "string",
|
||||||
|
title: "分支名称",
|
||||||
|
description: "要构建的Git分支名称",
|
||||||
|
default: "main"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: ["nodeName", "nodeCode", "jenkinsUrl", "jobName", "username", "apiToken"]
|
||||||
|
},
|
||||||
|
|
||||||
|
// 输入映射Schema - 定义从上游节点接收的数据
|
||||||
|
inputMappingSchema: {
|
||||||
|
type: "object",
|
||||||
|
title: "输入映射",
|
||||||
|
description: "从上游节点接收的数据映射配置",
|
||||||
|
properties: {
|
||||||
|
sourceCodeUrl: {
|
||||||
|
type: "string",
|
||||||
|
title: "源代码仓库地址",
|
||||||
|
description: "Git仓库的URL地址",
|
||||||
|
default: "${upstream.gitUrl}"
|
||||||
|
},
|
||||||
|
buildParameters: {
|
||||||
|
type: "object",
|
||||||
|
title: "构建参数",
|
||||||
|
description: "传递给Jenkins Job的构建参数",
|
||||||
|
properties: {},
|
||||||
|
additionalProperties: true,
|
||||||
|
default: {}
|
||||||
|
},
|
||||||
|
environmentVariables: {
|
||||||
|
type: "object",
|
||||||
|
title: "环境变量",
|
||||||
|
description: "构建时的环境变量",
|
||||||
|
properties: {},
|
||||||
|
additionalProperties: true,
|
||||||
|
default: {}
|
||||||
|
},
|
||||||
|
commitId: {
|
||||||
|
type: "string",
|
||||||
|
title: "提交ID",
|
||||||
|
description: "要构建的Git提交ID",
|
||||||
|
default: "${upstream.commitId}"
|
||||||
|
},
|
||||||
|
projectName: {
|
||||||
|
type: "string",
|
||||||
|
title: "项目名称",
|
||||||
|
description: "项目的名称标识",
|
||||||
|
default: "${upstream.projectName}"
|
||||||
|
},
|
||||||
|
buildVersion: {
|
||||||
|
type: "string",
|
||||||
|
title: "构建版本",
|
||||||
|
description: "构建版本号",
|
||||||
|
default: "${upstream.version}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: ["sourceCodeUrl", "buildParameters"]
|
||||||
|
},
|
||||||
|
|
||||||
|
// 输出映射Schema - 定义传递给下游节点的数据
|
||||||
|
outputMappingSchema: {
|
||||||
|
type: "object",
|
||||||
|
title: "输出映射",
|
||||||
|
description: "传递给下游节点的数据映射配置",
|
||||||
|
properties: {
|
||||||
|
buildId: {
|
||||||
|
type: "string",
|
||||||
|
title: "构建ID",
|
||||||
|
description: "Jenkins构建的唯一标识符",
|
||||||
|
default: "${jenkins.buildNumber}"
|
||||||
|
},
|
||||||
|
buildStatus: {
|
||||||
|
type: "string",
|
||||||
|
title: "构建状态",
|
||||||
|
description: "构建完成状态",
|
||||||
|
enum: ["SUCCESS", "FAILURE", "UNSTABLE", "ABORTED", "NOT_BUILT"],
|
||||||
|
default: "SUCCESS"
|
||||||
|
},
|
||||||
|
buildUrl: {
|
||||||
|
type: "string",
|
||||||
|
title: "构建URL",
|
||||||
|
description: "Jenkins构建页面的URL",
|
||||||
|
default: "${jenkins.buildUrl}"
|
||||||
|
},
|
||||||
|
buildDuration: {
|
||||||
|
type: "number",
|
||||||
|
title: "构建耗时",
|
||||||
|
description: "构建耗时(毫秒)",
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
artifactsUrl: {
|
||||||
|
type: "string",
|
||||||
|
title: "构建产物URL",
|
||||||
|
description: "构建产物的下载地址",
|
||||||
|
default: "${jenkins.artifactsUrl}"
|
||||||
|
},
|
||||||
|
consoleLog: {
|
||||||
|
type: "string",
|
||||||
|
title: "控制台日志",
|
||||||
|
description: "构建的控制台输出日志",
|
||||||
|
default: "${jenkins.consoleText}"
|
||||||
|
},
|
||||||
|
testResults: {
|
||||||
|
type: "object",
|
||||||
|
title: "测试结果",
|
||||||
|
description: "构建中的测试结果统计",
|
||||||
|
properties: {
|
||||||
|
totalCount: { type: "number", title: "总测试数", default: 0 },
|
||||||
|
passCount: { type: "number", title: "通过数", default: 0 },
|
||||||
|
failCount: { type: "number", title: "失败数", default: 0 },
|
||||||
|
skipCount: { type: "number", title: "跳过数", default: 0 }
|
||||||
|
},
|
||||||
|
default: {
|
||||||
|
totalCount: 0,
|
||||||
|
passCount: 0,
|
||||||
|
failCount: 0,
|
||||||
|
skipCount: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buildParameters: {
|
||||||
|
type: "object",
|
||||||
|
title: "构建参数",
|
||||||
|
description: "实际使用的构建参数",
|
||||||
|
properties: {},
|
||||||
|
additionalProperties: true,
|
||||||
|
default: {}
|
||||||
|
},
|
||||||
|
commitInfo: {
|
||||||
|
type: "object",
|
||||||
|
title: "提交信息",
|
||||||
|
description: "构建对应的Git提交信息",
|
||||||
|
properties: {
|
||||||
|
commitId: { type: "string", title: "提交ID" },
|
||||||
|
commitMessage: { type: "string", title: "提交消息" },
|
||||||
|
commitAuthor: { type: "string", title: "提交作者" },
|
||||||
|
commitTimestamp: { type: "string", title: "提交时间" }
|
||||||
|
},
|
||||||
|
default: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
required: ["buildId", "buildStatus", "buildUrl"]
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user