增加脚本适配工厂

This commit is contained in:
戚辰先生 2024-12-08 22:33:27 +08:00
parent 8155dc3eb9
commit 4b4d35fccd
2 changed files with 71 additions and 26 deletions

View File

@ -27,7 +27,7 @@ public abstract class NodeConfig {
/** /**
* 节点ID * 节点ID
*/ */
private String nodeId; private String id;
/** /**
* 节点名称 * 节点名称

View File

@ -296,28 +296,54 @@ true, NOW(), 'system', NOW(), 'system', 1, false),
true, NOW(), 'system', NOW(), 'system', 1, false), true, NOW(), 'system', NOW(), 'system', 1, false),
-- 任务节点类型 -- 任务节点类型
(2003, 'SHELL', 'Shell脚本节点', '执行Shell脚本的任务节点', 'TASK', 'code', '#1890ff', (2003, 'SCRIPT', '脚本执行节点', '执行各种脚本语言的节点', 'TASK', 'code', '#13c2c2',
'[{ '[{
"code": "SHELL", "code": "SCRIPT",
"name": "Shell脚本执行器", "name": "脚本执行器",
"description": "执行Shell脚本支持配置超时时间和工作目录", "description": "支持执行多种脚本语言Shell、Python、JavaScript等",
"configSchema": { "configSchema": {
"type": "object", "type": "object",
"required": ["script"], "required": ["script", "language", "interpreter"],
"properties": { "properties": {
"script": { "script": {
"type": "string", "type": "string",
"title": "脚本内容", "title": "脚本内容",
"format": "shell", "format": "textarea",
"description": "需要执行的Shell脚本内容" "description": "需要执行的脚本内容,例如:\\n#!/bin/bash\\necho \\"\\"\\nls -la\\necho \\"\\""
}, },
"timeout": { "language": {
"type": "number", "type": "string",
"title": "超时时间", "title": "脚本语言",
"description": "脚本执行的最大时间(秒)", "enum": ["shell", "python", "javascript", "groovy"],
"minimum": 1, "enumNames": ["Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"],
"maximum": 3600, "default": "shell",
"default": 300 "description": "脚本语言类型",
"oneOf": [
{
"const": "shell",
"title": "Shell脚本"
},
{
"const": "python",
"title": "Python脚本",
"readOnly": true
},
{
"const": "javascript",
"title": "JavaScript脚本",
"readOnly": true
},
{
"const": "groovy",
"title": "Groovy脚本",
"readOnly": true
}
]
},
"interpreter": {
"type": "string",
"title": "解释器路径",
"description": "脚本解释器的路径,例如:/bin/bash, /usr/bin/python3"
}, },
"workingDirectory": { "workingDirectory": {
"type": "string", "type": "string",
@ -325,15 +351,23 @@ true, NOW(), 'system', NOW(), 'system', 1, false),
"description": "脚本执行的工作目录", "description": "脚本执行的工作目录",
"default": "/tmp" "default": "/tmp"
}, },
"timeout": {
"type": "integer",
"title": "超时时间",
"description": "脚本执行的最大时间(秒)",
"minimum": 1,
"maximum": 3600,
"default": 300
},
"retryTimes": { "retryTimes": {
"type": "number", "type": "integer",
"title": "重试次数", "title": "重试次数",
"minimum": 0, "minimum": 0,
"maximum": 10, "maximum": 10,
"default": 0 "default": 0
}, },
"retryInterval": { "retryInterval": {
"type": "number", "type": "integer",
"title": "重试间隔(秒)", "title": "重试间隔(秒)",
"minimum": 1, "minimum": 1,
"maximum": 3600, "maximum": 3600,
@ -343,19 +377,31 @@ true, NOW(), 'system', NOW(), 'system', 1, false),
"type": "object", "type": "object",
"title": "环境变量", "title": "环境变量",
"description": "脚本执行时的环境变量", "description": "脚本执行时的环境变量",
"additionalProperties": {"type": "string"} "additionalProperties": {
"type": "string"
}
}, },
"successExitCode": { "successExitCode": {
"type": "number", "type": "integer",
"title": "成功退出码", "title": "成功退出码",
"description": "脚本执行成功的退出码", "description": "脚本执行成功的退出码",
"default": 0 "default": 0
},
"supportedLanguages": {
"type": "array",
"title": "支持的脚本语言",
"items": {
"type": "string",
"enum": ["shell", "python", "javascript", "groovy"]
},
"default": ["shell"]
} }
} }
} }
}]', }]',
'{ '{
"type": "object", "type": "object",
"required": ["name", "executor"],
"properties": { "properties": {
"name": { "name": {
"type": "string", "type": "string",
@ -371,13 +417,12 @@ true, NOW(), 'system', NOW(), 'system', 1, false),
"executor": { "executor": {
"type": "string", "type": "string",
"title": "执行器", "title": "执行器",
"enum": ["SHELL"], "enum": ["SCRIPT"],
"enumNames": ["Shell脚本执行器"] "enumNames": ["脚本执行器"]
} }
}, }
"required": ["name", "executor"]
}', }',
'{"name": "Shell脚本", "executor": "SHELL"}', '{"name": "脚本执行", "executor": "SCRIPT"}',
true, NOW(), 'system', NOW(), 'system', 1, false), true, NOW(), 'system', NOW(), 'system', 1, false),
-- Git节点类型 -- Git节点类型