Reputation: 3923
I am attempting to trigger a Jenkins build remotely via curl that has required parameters. These parameters are in the form of a static pull down.
I am able to trigger the build remotely via curl, but the parameters are not being passed - it appears that it is just taking the first (default) from each pull down.
Here is the curl command:
export json="{\"parameter\": [{\"name\": \"ENV\", \"value\": \"dev-1\"},{\"name\": \"PLATFORM\", \"value\": \"desktop\"},{\"name\": \"PRODUCT\", \"value\": \"Test\"}]}"
curl -H ".crumb:xxxxxxxxxxxxxxxxxxxxxx" -X POST http://server:8080/job/job_name/buildWithParameters -d token=tokenId --data-urlencode json="$json"
From what I can tell the JSON is valid - is there a different set of elements required for a static pull down list?
Thanks!
Upvotes: 1
Views: 2968
Reputation: 1984
Use http://server:8080/job/job_name/build
instead of buildWithParameters
, as shown in the example for using the remote access api.
I'm not sure what's the reason for the difference, and it was a bit confusing for me at first, but when using buildWithParameters
you need to add the parameters to the url as you found out with your wget command - and at the same time you can also add parameters when using the normal build
trigger.
Note that when you trigger a build this way, it will still work if you leave out some parameters, but for those the default value won't be used (they will be unspecified).
Upvotes: 3
Reputation: 3923
I got this to work using wget instead of curl, but I'd still be interested in knowing how to make this work with curl if anyone has pointers.
This command works:
wget --delete-after --auth-no-challenge --http-user=${userID} --http-password=${authToken} http://server:8080/job/job_name/buildWithParameters?token=runme\&ENV='dev-1'\&PLATFORM='desktop'\&PRODUCT='Test'
Upvotes: 2