2016-02-17 72 views
1

Rundeck支持通过API触发作业。 API文档可在documentation下获得。通过API触发Rundeck作业

我们正在使用API​​版本13,它尚不支持application/json。因此我需要使用基于XML的请求。

在我以前的尝试,我总是得到回应:

<result error="true" apiversion="13"> <error code="api.error.job.options-invalid"> <message>Job options were not valid: Option 'container' is required. Option 'version' is required. </message> </error> </result>

由于没有提供,我正在寻找一个例子有效载荷触发这个工作没有例子请求。

正如在响应中看到的,我必须提供参数“容器”和“版本”,因为它们是必需的。

我最近的请求负载是:

<executeJob> <argString>-container containerName -version 1234567</argString> </executeJob>

我也试过这个有效载荷,具有相同的响应每一次的不同变化。

回答

3

这会帮助你,假设你有一个令牌来访问Rundeck授权而运行作业

curl -D - -X "POST" -H "Accept: application/json" \ 
    -H "Content-Type: application/json" \ 
    -H "X-Rundeck-Auth-Token: <TOKEN>" \ 
    -d '{"argString":"-arg1 val1 -arg2 val2"}' \ 
http://<URL>/api/16/job/<JOB_ID>/executions