0

I am trying to trigger the Jenkins build with the curl command with the argument passed as "users". I am trying to send the values externally. But every time I run the build it picks up only the first value declared in the choice parameters whatever may be the value which I passed using the curl command line. So is anyone suggest the workaround on this.

Eg. My Jenkins job has a choice parameter named users with 4 values 1,2,3,4 etc.

When I trigger build with curl -

curl -v -X POST http://localhost:9999/job/gatling/buildWithParameters --data token=11ceefa59d2017b21b3d637ece05742fd5 --user admin:admin --data-urlencode json= '{"users":"3", "duration":"10", "feature":"asset", "load_simulation":"AtOnceUserSimulation"}'

I am passing the value as "users":"3" but value gets passed as 1 in the build.

Can anyone suggest a solution for this?

Rocky
  • 21
  • 6

1 Answers1

0

Remote access API states that json value should have parameter key with list of name-value pairs:

curl -X POST JENKINS_URL/job/JOB_NAME/buildWithParameters \
  --user USER:TOKEN \
  --data-urlencode json='{"parameter": [{"name":"id", "value":"123"}, {"name":"verbosity", "value":"high"}]}'
y_ug
  • 904
  • 6
  • 8
  • Hey, It won't work for me - Build still gets triggered without the parameter value not getting passed from command line. Not sure but I think it might be due to any changes happened in the Jenkins API as we are passing the values as body to the post request. – Rocky Mar 12 '20 at 08:54
  • There were some similar questions earlier about curl and choice parameters. E.g. https://stackoverflow.com/questions/49525677/jenkins-pipeline-how-to-give-choice-parameters-dynamically, https://stackoverflow.com/questions/41759405/jenkins-choice-parameter-passing-to-a-pipeline-job, https://stackoverflow.com/questions/52771348/how-to-pass-parameter-in-curl-while-calling-jenkins-job-without-using-buildwithp, https://stackoverflow.com/questions/22607368/jenkins-pass-multiple-extended-choice-parameter-values-using-a-url. If nothis helps, please, do provide code of your pipeline. – y_ug Mar 13 '20 at 10:29