2016-02-17 115 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