-
Notifications
You must be signed in to change notification settings - Fork 8
/
task.json
219 lines (218 loc) · 13.4 KB
/
task.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{
"atomCode": "executeJobScript",
"execution": {
"packagePath": "executeJobScript-jar-with-dependencies.jar",
"language": "java",
"minimumVersion": "1.8",
"demands": [],
"target": "$bk_java_path -Dfile.encoding=utf8 -jar executeJobScript-jar-with-dependencies.jar"
},
"input": {
"bizId": {
"label": "业务 ID(App ID)",
"default": "",
"type": "vuex-input",
"desc": "Job 中登记的业务 ID(App ID in Job platform)",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": false
},
"scriptType": {
"label": "脚本类型(Script Type)",
"default": "1",
"placeholder": "",
"type": "enum-input",
"list": [
{
"label": "shell",
"value": "1"
},
{
"label": "bat",
"value": "2"
},
{
"label": "perl",
"value": "3"
},
{
"label": "python",
"value": "4"
},
{
"label": "powershell",
"value": "5"
}
],
"desc": "",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": false
},
"tipsNotDel": {
"type": "tips",
"label": "",
"tipStr": "请勿删除脚本模板首行内容,可在脚本末尾处编写您的业务代码,建议在脚本首尾及关键分支位置打印日志(Please do not delete the first line of script template. You can add your script content to the end of the script template. Logging at the start, end and key point of script is recommended.)"
},
"tipsFailHandle": {
"type": "tips",
"label": "",
"tipStr": "若执行失败,请根据使用的蓝鲸版本点击插件日志中对应的链接前往作业平台查看脚本失败详情,若为脚本执行超时失败,请检查脚本自身逻辑有无死循环或耗时操作,若正常逻辑耗时较长请调整插件的超时参数(If script fail, please click the link in the log and go to Job to check the detail of script failure. If script fail because of timeout, please check whether there is a dead loop or long-time operation in script content. If the normal business logic requires long time, please adjust the timeout parameter of this plugin.)"
},
"scriptContent": {
"label": "脚本内容(Script Content)",
"default": "",
"placeholder": "",
"type": "atom-ace-editor",
"desc": "兼容老版本插件保留下的字段",
"required": false,
"disabled": false,
"hidden": true,
"isSensitive": false
},
"shellScriptContent": {
"type": "atom-ace-editor",
"label": "脚本内容",
"desc": "将会在目标服务器执行脚本",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": true,
"default": "#!/bin/bash\n\nanynowtime=\"date +'%Y-%m-%d %H:%M:%S'\"\nNOW=\"echo [\\`$anynowtime\\`][PID:$$]\"\n\n##### 可在脚本开始运行时调用,打印当时的时间戳及PID。\nfunction job_start\n{\n echo \"`eval $NOW` job_start\"\n}\n\n##### 可在脚本执行成功的逻辑分支处调用,打印当时的时间戳及PID。\nfunction job_success\n{\n MSG=\"$*\"\n echo \"`eval $NOW` job_success:[$MSG]\"\n exit 0\n}\n\n##### 可在脚本执行失败的逻辑分支处调用,打印当时的时间戳及PID。\nfunction job_fail\n{\n MSG=\"$*\"\n echo \"`eval $NOW` job_fail:[$MSG]\"\n exit 1\n}\n\njob_start\n\n###### 可在此处开始编写您的脚本逻辑代码\n###### 作业平台中执行脚本成功和失败的标准只取决于脚本最后一条执行语句的返回值\n###### 如果返回值为0,则认为此脚本执行成功,如果非0,则认为脚本执行失败",
"rely": {
"operation": "AND",
"expression": [
{
"key": "scriptType",
"value": "1"
}
]
}
},
"batScriptContent": {
"type": "atom-ace-editor",
"label": "脚本内容",
"desc": "将会在目标服务器执行脚本",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": true,
"default": "@echo on\nsetlocal enabledelayedexpansion\ncall:job_start\n\nREM 可在此处开始编写您的脚本逻辑代码\nREM 作业平台中执行脚本成功和失败的标准只取决于脚本最后一条执行语句的返回值\nREM 如果返回值为0,则认为此脚本执行成功,如果非0,则认为脚本执行失败\n\n\n\nREM 函数定定义区域,不要把正文写到函数区下面\ngoto:eof\nREM 可在脚本开始运行时调用,打印当时的时间戳及PID。\n:job_start\n set cu_time=[%date:~0,10% %time:~0,8%]\n for /F \"skip=3 tokens=2\" %%i in ('tasklist /v /FI \"IMAGENAME eq cmd.exe\" /FI \"STATUS eq Unknown\"') do (\n set pid=[PID:%%i]\n goto:break\n )\n :break\n echo %cu_time%%pid% job_start\n goto:eof\n\nREM 可在脚本执行成功的逻辑分支处调用,打印当时的时间戳及PID。\n:job_success\n set cu_time=[%date:~0,10% %time:~0,8%]\n for /F \"skip=3 tokens=2\" %%i in ('tasklist /v /FI \"IMAGENAME eq cmd.exe\" /FI \"STATUS eq Unknown\"') do (\n set pid=[PID:%%i]\n goto:break\n )\n :break\n echo %cu_time%%pid% job_success:[%*]\n exit 0\n\nREM 可在脚本执行失败的逻辑分支处调用,打印当时的时间戳及PID。\n:job_fail\n set cu_time=[%date:~0,10% %time:~0,8%]\n for /F \"skip=3 tokens=2\" %%i in ('tasklist /v /FI \"IMAGENAME eq cmd.exe\" /FI \"STATUS eq Unknown\"') do (\n set pid=[PID:%%i]\n goto:break\n )\n :break\n echo %cu_time%%pid% job_fail:[%*]\n exit 1\n",
"rely": {
"operation": "AND",
"expression": [
{
"key": "scriptType",
"value": "2"
}
]
}
},
"perlScriptContent": {
"type": "atom-ace-editor",
"label": "脚本内容",
"desc": "将会在目标服务器执行脚本",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": true,
"default": "#!/usr/bin/perl\n\nuse strict;\n\nsub job_localtime {\n my @n = localtime();\n return sprintf(\"%04d-%02d-%02d %02d:%02d:%02d\",$n[5]+1900,$n[4]+1,$n[3], $n[2], $n[1], $n[0] );\n}\n\n##### 可在脚本开始运行时调用,打印当时的时间戳及PID。\nsub job_start {\n print \"[\",&job_localtime,\"][PID:$$] job_start\n\";\n}\n\n##### 可在脚本执行成功的逻辑分支处调用,打印当时的时间戳及PID。\nsub job_success {\n print \"[\",&job_localtime,\"][PID:$$] job_success:[@_]\n\";\n exit 0;\n}\n\n##### 可在脚本执行失败的逻辑分支处调用,打印当时的时间戳及PID。\nsub job_fail {\n print \"[\",&job_localtime,\"][PID:$$] job_fail:[@_]\n\";\n exit 1;\n}\n\njob_start;\n\n###### 可在此处开始编写您的脚本逻辑代码\n###### 如果返回值为0,则认为此脚本执行成功,如果非0,则认为脚本执行失败\n",
"rely": {
"operation": "AND",
"expression": [
{
"key": "scriptType",
"value": "3"
}
]
}
},
"pythonScriptContent": {
"type": "atom-ace-editor",
"label": "脚本内容",
"desc": "将会在目标服务器执行脚本",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": true,
"default": "#!/usr/bin/env python\n# -*- coding: utf8 -*-\n\nimport datetime\nimport os\nimport sys\n\ndef _now(format=\"%Y-%m-%d %H:%M:%S\"):\n return datetime.datetime.now().strftime(format)\n\n##### 可在脚本开始运行时调用,打印当时的时间戳及PID。\ndef job_start():\n print \"[%s][PID:%s] job_start\" % (_now(), os.getpid())\n\n##### 可在脚本执行成功的逻辑分支处调用,打印当时的时间戳及PID。\ndef job_success(msg):\n print \"[%s][PID:%s] job_success:[%s]\" % (_now(), os.getpid(), msg)\n sys.exit(0)\n\n##### 可在脚本执行失败的逻辑分支处调用,打印当时的时间戳及PID。\ndef job_fail(msg):\n print \"[%s][PID:%s] job_fail:[%s]\" % (_now(), os.getpid(), msg)\n sys.exit(1)\n\nif __name__ == '__main__':\n\n job_start()\n\n###### 可在此处开始编写您的脚本逻辑代码\n###### iJobs中执行脚本成功和失败的标准只取决于脚本最后一条执行语句的返回值\n###### 如果返回值为0,则认为此脚本执行成功,如果非0,则认为脚本执行失败\n",
"rely": {
"operation": "AND",
"expression": [
{
"key": "scriptType",
"value": "4"
}
]
}
},
"powershellScriptContent": {
"type": "atom-ace-editor",
"label": "脚本内容",
"desc": "将会在目标服务器执行脚本",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": true,
"default": "##### 可在脚本开始运行时调用,打印当时的时间戳及PID。\nfunction job_start\n{\n $cu_date = Get-Date -Format \"yyyy-MM-dd HH:mm:ss\"\n \"[{0}][PID:{1}] job_start\" -f $cu_date,$pid\n}\n\n##### 可在脚本执行成功的逻辑分支处调用,打印当时的时间戳及PID。\nfunction job_success\n{\n $cu_date = Get-Date -Format \"yyyy-MM-dd HH:mm:ss\"\n if($args.count -ne 0)\n {\n $args | foreach {$arg_str=$arg_str + \" \" + $_}\n \"[{0}][PID:{1}] job_success:[{2}]\" -f $cu_date,$pid,$arg_str.TrimStart(' ')\n }\n else\n {\n \"[{0}][PID:{1}] job_success:[]\" -f $cu_date,$pid\n }\n exit 0\n}\n\n##### 可在脚本执行失败的逻辑分支处调用,打印当时的时间戳及PID。\nfunction job_fail\n{\n $cu_date = Get-Date -Format \"yyyy-MM-dd HH:mm:ss\"\n if($args.count -ne 0)\n {\n $args | foreach {$arg_str=$arg_str + \" \" + $_}\n \"[{0}][PID:{1}] job_fail:[{2}]\" -f $cu_date,$pid,$arg_str.TrimStart(' ')\n }\n else\n {\n \"[{0}][PID:{1}] job_fail:[]\" -f $cu_date,$pid\n }\n exit 1\n}\n\njob_start\n\n###### 可在此处开始编写您的脚本逻辑代码\n###### 作业平台中执行脚本成功和失败的标准只取决于脚本最后一条执行语句的返回值\n###### 如果返回值为0,则认为此脚本执行成功,如果非0,则认为脚本执行失败\n",
"rely": {
"operation": "AND",
"expression": [
{
"key": "scriptType",
"value": "5"
}
]
}
},
"scriptParam": {
"label": "脚本参数(Script Parameters)",
"default": "",
"desc": "脚本执行参数,多个参数用空格分隔。示例: param1 param2(Script Parameters, separated by space, ex:param1 param2)",
"type": "vuex-input",
"required": false
},
"timeout": {
"label": "超时时间(Timeout,单位为秒,范围60-72000)",
"default": "1000",
"type": "vuex-input",
"desc": "请输入脚本执行超时时间,单位为秒,范围60-72000,默认1000(Please input script timeout, time unit:second, range:60-72000, default:1000)",
"required": true
},
"account": {
"label": "执行账号(Account)",
"default": "root",
"placeholder": "",
"type": "vuex-input",
"desc": "",
"required": true,
"disabled": false,
"hidden": false,
"isSensitive": false
},
"targetIpList": {
"label": "手工录入(云区域ID:IP)(Manual Input:(cloud area id:ip)",
"default": "",
"placeholder": "请输入目标 IP 列表(云区域ID:IP)\n如:82:172.1.2.3,多个ip之间用,;换行符中的任意一个进行分隔\n(Please input target IP list:(cloud area id:ip)\nex: 82:172.1.2.3, separated by one of[,;] or a line break when there are few IPs)",
"desc": "云区域ID:IP\n如:82:172.1.2.3\n多个ip之间用,;换行符中的任意一个进行分隔((cloud area id:ip)\nex: 82:172.1.2.3, separated by one of[,;] or a line break when there are few IPs)",
"type": "vuex-textarea",
"required": false,
"disabled": false,
"hidden": false,
"isSensitive": false
},
"dynamicGroupIdList": {
"label": "动态分组ID列表(Dynamic Group IDs)",
"default": "",
"placeholder": "请输入动态分组ID(从CMDB获取)列表\n如:brcfabc2si9h3j4v3qb1,多个ID之间用,;换行符中的任意一个进行分隔(注意:若对接蓝鲸6.x中的作业平台,请在动态分组ID前加上\"具体的业务ID:\",对接5.x中的作业平台则不需要)\n(Please input Dynamic Group IDs (Can be acquired from CMDB),ex: brcfabc2si9h3j4v3qb1, separated by one of[,;] or a line break when there are few IDs)(Important:please add \"[AppID]:\" before every Dynamic Group ID if you use this plugin to invoke Job in BlueKing6.0)",
"desc": "动态分组ID\n如:brcfabc2si9h3j4v3qb1\n多个ID之间用,;换行符中的任意一个进行分隔(注意:若对接蓝鲸6.x中的作业平台,请在动态分组ID前加上\"具体的业务ID:\",对接5.x中的作业平台则不需要)\n(Dynamic Group IDs, ex:brcfabc2si9h3j4v3qb1, separated by one of[,;] or a line break when there are few IDs)(Important:please add \"[AppID]:\" before every Dynamic Group ID if you use this plugin to invoke Job in BlueKing6.0)",
"type": "vuex-textarea",
"required": false,
"disabled": false,
"hidden": false,
"isSensitive": false
}
}
}