With a little tinkering of the Job Token we are able to use the Jenkins Extension to run a new Job. However the API is way more capable and the extension does not have those features, so I tried using the HTTP POST action to accommodate.
The 2 common thing we need to do:
- Create a new Job
- Update an existing Job
They both require a file or big textblock of the config.xml and they both require authentication. I am able to accomplish these tasks with an HTTP Chrome plugin (Postman), so I know the following code works when I apply a binary file containing the config.xml. The login/password are entered into plugin and it returns the basic authentication key, which I cleaned up below to just be "xyz123"
curl -X POST -H "Content-Type: application/xml" -H "Authorization: Basic xyz123" "http://Jenkins:8080/job/createItem?name=TestNewAPIJob" --data-binary @config.xml
curl -X POST -H "Content-Type: application/xml" -H "Authorization: Basic xyz123" "http://Jenkins:8080/job/TestNewAPIJob/config.xml" --data-binary @config.xml
In BuildMaster I am having trouble and always receive a 403 authentication error. I dont know if there is an issue with the syntax for RequestHeaders and how I pass in the authentication, of if there is a way for BuildMaster to create the authentication string based on login settings.
I do have everything working right now using BuildMaster to create the config, and then kicking off the cURL request as a simple bat file, but it would be nice if I dont need to install cURL, and can just do everything with the application.