使用 Rundeck webhook 插件从 post 请求中获取数据
Get data from post request with Rundeck webhook plugin
我正在尝试使用 rundeck webhook 插件获取数据,为此我正在使用 curl 命令:
curl -X POST -d '{"name":"John", "age":30, "car":null}' https://rundeck_server/api/12/webhook/QSxTDYd08dcYxKh1R5YJNOPQvmSJH2Z8#Netbox_Job
在 rundeck webhook 插件选项中,我添加了这两个变量,'whkpayload' 获取所有 json 数据,'name' 仅获取名称(必须 return John在这个例子中):
-whkpayload ${raw} -name ${data.name}
最后我向他们展示了这些台词:
echo @option.whkpayload@
echo @option.name@
我得到一个空的结果,我不知道为什么。任何人都可以帮助我吗?
在this之后,您需要在作业中使用名为whkpayload
的选项,并在webhook配置中将其设置为${raw}
。
我举了个例子:
- YAML 格式的作业定义(使用
whkpayload
选项):
- defaultTab: nodes
description: ''
executionEnabled: true
id: 0fcfca07-02f6-4583-a3eb-0002276bdf2d
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
options:
- name: age
- name: car
- name: name
- name: whkpayload
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- description: command step
exec: echo "name ${option.name} - age ${option.age} - car ${option.car} - payload
${option.whkpayload}"
- description: inline-script step
fileExtension: .sh
interpreterArgsQuoted: false
script: echo "name @option.name@ - age @option.age@ - car @option.car@ - payload
@option.whkpayload@"
scriptInterpreter: /bin/bash
keepgoing: false
strategy: node-first
uuid: 0fcfca07-02f6-4583-a3eb-0002276bdf2d
webhook configuration.
从 cURL 调用的 webhook:
curl -H "Content-Type: application/json" -X POST -d '{"field1":"John", "field2":30, "field3":"chevy"}' http://localhost:4440/api/40/webhook/0vBZjWWrnXWvqENEdxkn0JRvjn5R63J0#MyWebhook
我正在尝试使用 rundeck webhook 插件获取数据,为此我正在使用 curl 命令:
curl -X POST -d '{"name":"John", "age":30, "car":null}' https://rundeck_server/api/12/webhook/QSxTDYd08dcYxKh1R5YJNOPQvmSJH2Z8#Netbox_Job
在 rundeck webhook 插件选项中,我添加了这两个变量,'whkpayload' 获取所有 json 数据,'name' 仅获取名称(必须 return John在这个例子中):
-whkpayload ${raw} -name ${data.name}
最后我向他们展示了这些台词:
echo @option.whkpayload@
echo @option.name@
我得到一个空的结果,我不知道为什么。任何人都可以帮助我吗?
在this之后,您需要在作业中使用名为whkpayload
的选项,并在webhook配置中将其设置为${raw}
。
我举了个例子:
- YAML 格式的作业定义(使用
whkpayload
选项):
- defaultTab: nodes
description: ''
executionEnabled: true
id: 0fcfca07-02f6-4583-a3eb-0002276bdf2d
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
options:
- name: age
- name: car
- name: name
- name: whkpayload
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- description: command step
exec: echo "name ${option.name} - age ${option.age} - car ${option.car} - payload
${option.whkpayload}"
- description: inline-script step
fileExtension: .sh
interpreterArgsQuoted: false
script: echo "name @option.name@ - age @option.age@ - car @option.car@ - payload
@option.whkpayload@"
scriptInterpreter: /bin/bash
keepgoing: false
strategy: node-first
uuid: 0fcfca07-02f6-4583-a3eb-0002276bdf2d
webhook configuration.
从 cURL 调用的 webhook:
curl -H "Content-Type: application/json" -X POST -d '{"field1":"John", "field2":30, "field3":"chevy"}' http://localhost:4440/api/40/webhook/0vBZjWWrnXWvqENEdxkn0JRvjn5R63J0#MyWebhook