rundeck - Rundeck - 作业导入不适用于 yaml
问题描述
我正在使用这个 Rundeck 作业导入的 API,从我当地的邮递员那里,我可以使用正文中给定的 yaml 进行作业导入。
但是当我尝试对本地的 curl 执行相同操作时,它失败了:
[root@vms ]# curl -k --location --request POST 'rundeck-host:4443/api/14/project/project-name/jobs/import' --header 'Content-Type: application/yaml' --header 'X-Rundeck-Auth-Token: my-token' --data @job.yaml
<result error='true' apiversion='33'>
<error code='api.error.jobs.import.invalid'>
<message>Jobs Document was invalid for format xml: mapping values are not allowed here
in 'reader', line 1, column 33:
- defaultTab: nodes description: '' executionEnabled: true gr ...
^
</message>
</error>
</result>
即使在使用fileformat=yaml等所有选项付出了很多之后,它也不起作用。
请让我知道我做错了什么。
解决方案
它适用于以下调用(在 Rundeck 3.3.10 上测试):
#!/bin/sh
# protocol
protocol="http"
# basic rundeck info
rdeck_host="localhost"
rdeck_port="4440"
rdeck_api="38"
rdeck_token="2aoZkhOR0ZSwMIZo4Sg6hrY57NfiN4nB"
# specific api call info
rdeck_project="ProjectEXAMPLE"
rdeck_yaml_file="job.yaml"
# api call
curl -kSsv --header "X-Rundeck-Auth-Token:$rdeck_token" \
-F xmlBatch=@"$rdeck_yaml_file" \
"$protocol://$rdeck_host:$rdeck_port/api/$rdeck_api/project/$rdeck_project/jobs/import?fileformat=yaml"
以及以下作业定义示例(job.yaml 文件):
- defaultTab: nodes
description: ''
executionEnabled: true
id: 24d326d4-5fa9-4f42-98d6-b27b338fa7ff
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- exec: echo "hi"
keepgoing: false
strategy: node-first
uuid: 24d326d4-5fa9-4f42-98d6-b27b338fa7ff
推荐阅读
- ios - 放大和缩小 SpriteKit 场景的数学
- c# - 如何在 c# windows 10 UWP 中圆化 App 主窗口的角?
- php - 为什么常规数据匹配条件在 ' 中不起作用
'?为什么它不给出输出? - java - 使用 MockMVC 对 RestController 端点进行单元测试,未按预期捕获预期的异常
- mongodb - 是否可以执行 mongodb 请求但返回 5 行,您的项目在中间?
- shell - 后 scp 文件传输无法对源和目标的路径进行校验和以进行比较
- c# - 如何翻转子对象的精灵?
- r - 当一个条件是值列表时如何应用过滤器
- javascript - 反应服务器端渲染 - 无法将数据从服务器处理程序文件传递到反应组件
- reactjs - 如何使用 React-Redux 进行搜索?