Search code examples
jenkinsrundeck

How to update(or create) Rundeck jobs Automatically using jenkins pipeline


I want to update the rundeck's XML file automatically whenever Jenkins builds Using a rundeck plugin.

I confirmed When they built Jenkins project(with rundeck plugin), they could run the rundeck jobs.(trigger)

But I couldn't find the ability to update the XML file automatically.

Am I not able to solve this using rundeck plugin?

I'm sorry if it's a redundant question.


Solution

  • Maybe the fastest way to do that is using the API, create some "step" on Jenkins that create the XML and then import through API.

    curl -kSsv --header "X-Rundeck-Auth-Token:YourUserToekn" -F xmlBatch=@"yourjob.xml" "http://yourhost:4440/api/31/project/YourProject/jobs/import?format=xml&dupeOption=update&uuidOption=remove"
    

    Check this:

    https://docs.rundeck.com/docs/api/#importing-jobs

    Also, you can test it using Postman:

    https://documenter.getpostman.com/view/95797/rundeck/7TNfX9k?version=latest#05e95338-0e70-a751-8975-b2809e45276e