Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger Rundeck Job via API

Tags:

rundeck

Rundeck supports triggering jobs via their API. The API documentation is available under documentation.

We are using API version 13 which does not yet support application/json. Therefore i need to use the XML based request.

In my previous attempts, i always get the response:

<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>

Since there is no example request provided, i am searching for an example payload to trigger the job.

As seen in the response i have to provide the parameters "container" and "version" since they are required.

My most recent request payload was:

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

I also tried different variations of this payload, every time with the same response.

like image 886
sebastian Avatar asked Feb 08 '23 17:02

sebastian


1 Answers

This should help you, assuming you have a token to access Rundeck with authorization to run the job

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
like image 66
swapz83 Avatar answered Jun 27 '23 01:06

swapz83