Hello,

This seems like a bug to me but, if so, I don't know how it hasn't been 
reported which makes me think I'm overlooking something obvious.

When I invoke a jenkins job via curl and send the parameters as JSON 
data\payload to the job's /build endpoint any parameters I don't pass in 
the payload disappear from the invoked build for that job (even if the 
parameters omitted have default values).

For instance, say I have a job test-job with the following parameters 
defined:

*String Parameter*
[image: [Help]] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Name [image: Help for feature: Name] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Default Value [image: Help for feature: Default Value] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Description 

 [Safe HTML] Preview 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
 
[image: Help for feature: Description] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Trim the string [image: Help for feature: This project is parameterized] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>

Delete
*String Parameter*
[image: [Help]] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Name [image: Help for feature: Name] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Default Value [image: Help for feature: Default Value] 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
  Description 

 [Safe HTML] Preview 
<http://d10b588.na.sas.com:8080/job/extend_choice_parameter_plugin_test/configure#>
 


If i invoke said job via curl using the /build endpoint:
curl --location --request POST 
'http://XXXXXXXXXXXXXXX:8080/job/test-job/build' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: XXXXXXXXXXXXXXXXXXXXXXX' \
--data-urlencode 
'json={"parameter":[{"name":"required_param","value":"myValue"}]}'

The default_param is dropped entirely from the resultant build:

Build #8
Parameters
  required_param 








Instead if I invoke the job via curl with url query params using the 
/buildWithParameters endpoint it works as I would expect:

curl --location --request POST 
'http://XXXXXXXXXXXXXXX:8080/job/test-job/buildWithParameters?required_param=myValue'
 
\
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: XXXXXXXXXXXXXXXXXXXXXXX'

Build #9
Parameters
  required_param 
  default_param 












Is there a bug with the /build endpoint WRT passing parameters as json data?

Thanks,
Jay



-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5313272d-8c6a-49c9-9509-94be90d71af9%40googlegroups.com.

Reply via email to