I am using the API for this Rundeck job import, from my local postman I could able to do the job import with the given yaml in the body.
but when I try to do the same with curl from my local it is failing:
[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>
Even after paying a lot with all the option like fileformate=yaml and other, it does not work.
Please let me know what I am doing wrong.
It works with the following call (tested on 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"
And the following job def example (job.yaml file):
- 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