Disclaimer: IMHO, this feature is poorly documented. I figured most of this out from a bunch of SO questions with partial answers and several blog articles, and very little from actual Jenkins docs. However, it seems to work nicely on Jenkins 2.73.2.
First, I think you need to add an id
attribute to your input
.
Then, you can send a POST request to one of these:
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/input/${INPUT_ID}/abort
This will cancel your job and ignore any parameter.
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/input/${INPUT_ID}/proceedEmpty
This will resume your job and ignore any parameter.
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/input/${INPUT_ID}/submit
This will resume your job, and you can send parameters. But:
- You will need to send a
proceed
parameter with the caption of the 'Proceed' button.
- You will need to send a
json
parameter with a URL-encoded JSON document with the form {"parameter":[{"name":"param1","value":"valueOfParam1"},{"name":"param2","value":"valueOfParam2"}]}
, these will be your actual input parameters.
- If you fail to send a valid
json
parameter, your job will continue anyway, it just won't get any parameter.
- On success, this will return a '302 Found' and a redirection to user interface, which might interfere with your code and/or cause error handling issues.
http://yourjenkins/job/${YOUR_PROJECT}/${BUILD_NUMBER}/wfapi/inputSubmit
This seems to be the right way. You need to send inputId
and json
(see previous point). On success, this will return a '200 OK' with an empty response. You can also check out /wfapi
and /wfapi/nextPendingInputAction
on a paused job for more information.
Keep in mind that you will need to send authentication credentials and CSRF token for each request. Also, for the use case you describe, you probably wouldn't need parameters for your input
, but just the proceed/abort built-in action.