运行 通过 rundeck 的工作 API 在 postman 中带有参数

Run a job via the rundeck API with parameters in postman

我正在尝试使用 Rundeck API。我能够得到一份简单的工作 运行ning。但现在我正在尝试 运行 一份有工作选择权的工作。这个作业的作业选项是一个 IP,所以 Rundeck 只在这台机器上启动作业。 当我使用 API 时,我不知道如何设置参数。我正在使用 Postman 工具,我只收到消息“作业选项无效:需要选项 'IP'”。

我在 rundeck documentation and I found this 上查找邮递员

运行deck 文档中有这个例子:

argString: argument string to pass to the job, of the form: -opt value -opt2 value ....

如何将其用于我的 IP?

使用这个 Rundeck Job Definition:

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 9f04657a-eaab-4e79-a5f3-00d3053f6cb0
  loglevel: INFO
  name: HelloWorld
  nodeFilterEditable: false
  options:
  - name: opt1
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - exec: echo "hello ${option.opt1}"
    keepgoing: false
    strategy: node-first
  uuid: 9f04657a-eaab-4e79-a5f3-00d3053f6cb0

并且基于this,您可以通过将选项以JSON格式(json正文)放在Postman上来实现:

{
    "options": {
        "opt1":"world"
    }
}

这是以 cURL 格式截取的代码:

curl --location --request POST 'pop-os:4440/api/38/job/9f04657a-eaab-4e79-a5f3-00d3053f6cb0/run' \
--header 'X-Rundeck-Auth-Token: GuaoD6PtH5BhobhE3bAPo4mGyfByjNya' \
--header 'Content-Type: application/json' \
--header 'Cookie: JSESSIONID=node01tz8yvp4gjkly8kpj18h8u5x42.node0' \
--data-raw '{
    "options": {
        "opt1":"world"
    }
}'

检查 looks 在 Postman 上的表现。