14

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.

Dawie Strauss
  • 3,706
  • 3
  • 23
  • 26

1 Answers1

27

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

http://<ci-host>/job/<jobname>/buildWithParameters
Jossef Harush Kadouri
  • 32,361
  • 10
  • 130
  • 129
Daniel S.
  • 628
  • 6
  • 12
  • 1
    Complications ensue with security / authorization in place. You can read some good pointers in [this answer](http://stackoverflow.com/a/16181067/366749). – Patrice M. Aug 01 '13 at 17:40