Fair enough but, for whatever reason, I can only get the parameters passed 
as JSON data when I use the /build endpoint.  If I POST to the 
/buildWithParameters endpoint, all parameters show up in the invoked build 
but with no values (other than defaults).

Using the same example with the following curl:
curl --location --request POST 
'http://XXXXXXXXXXXXXXXXXXX:8080/job/test-job/buildWithParameters' 
\
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: XXXXXXXXXXXXXXXXXXXXX' \
--data-urlencode 
'json={"parameter":[{"name":"required_param","value":"myValue"}]}'

Yields:
Build #11
Parameters
  required_param 
  default_param 











The default_param is now included with the correct default value but the 
value passed for the required_param is missing?



On Thursday, February 20, 2020 at 10:20:19 AM UTC-5, Mark Waite wrote:
>
> I suspect that is intentional.  I assume that the '/build' end point is 
> not intended for use with parameters.  If you want to pass parameters, use 
> the /buildWithParameters end point.
>
>
> On Thu, Feb 20, 2020 at 7:35 AM Jay Hayes <[email protected] 
> <javascript:>> wrote:
>
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/5313272d-8c6a-49c9-9509-94be90d71af9%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/5313272d-8c6a-49c9-9509-94be90d71af9%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/cac1ce31-e1ec-486d-ac12-27d22ae4404d%40googlegroups.com.

Reply via email to