I am triggering a parametrized Jenkins job remotely using the Remote Access API like this:
url=http://<ci-host>/job/<jobname>/build
json="{\"parameter\": [{\"name\": \"A_NAME\", \"value\": \"a_value\"}]}"
curl -X POST $url -d token=zorn --data-urlencode json="$json"
I want Jenkins to use the configured default value for one of my parameters, but it seems to be expecting values for all of the parameters.
If I leave out a parameter, the job sees it as an empty string.
Is there a way to make it use the configured default value for a parameter?
EDIT:
The solution (as per Daniel S.) was to use buildWithParameters
as follows:
url=http://<ci-host>/job/<jobname>/buildWithParameters
curl -s -X POST $url
ANOTHER EDIT:
But now the problem is that buildWithParameters
does not work on a job with no parameters. So it cannot be used for a generic script to start all my jobs.
Developers can follow these three steps to implement a remote Jenkins build trigger: Create a Jenkins build job and enable the Trigger builds remotely checkbox. Provide an authentication token; This can be any text string of your choice. Invoke the Jenkins build URL to remotely trigger the build job.
Once you've created the build job, Jenkins will display the item's configuration page. On this configuration page, there is an unselected checkbox next to text that states: "This project is parameterized." Select this option, and in the drop-down that subsequently appears, choose the option to add a Boolean parameter.
Configure a job to trigger from remote in Jenkins You can create a new FreeStyle job or you can use the previous one. Move to configuration -> Build Triggers sections and check the “Trigger builds remotely(e.g., from scripts)” option and paste the token name there.
Try to use buildWithParameters
instead of build
, i.e.
http://<ci-host>/job/<jobname>/buildWithParameters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With