13
votes

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.

1

1 Answers

27
votes

Try to use buildWithParameters instead of build, i.e.

http://<ci-host>/job/<jobname>/buildWithParameters