1

I am trying to call a Jenkins parameterized job using curl command. I am following Remote API Jenkins.

I have Active choice parameter plugin. One of the parameters of the job is an Active choice reactive parameter.

Here is the screenshot of the job:

enter image description here

I am using the following curl command to trigger it with parameter:

curl -X POST http://localhost:8080/job/active-choice-test/buildWithParameters -u abhishek:token --data-urlencode json='{"parameter": [{"name":"state", "value":"Maharashtra"},{"name":"cities", "value":["Mumbai", "Pune"]}]}'

But I am not able to pass the cities parameter which should be a json array. The above script is giving error.

I am printing the state & cities variable like this:

enter image description here

The job is getting executed and showing error for cities:

Started by user abhishek
Building in workspace /var/lib/jenkins/workspace/active-choice-test
[active-choice-test] $ /bin/sh -xe /tmp/hudson499503098295318443.sh
+ echo Maharashtra
Maharashtra
+ echo error
error
Finished: SUCCESS

Please tell me how to pass array parameter to a jenkins parameterized job while using remote access API?

abhishek
  • 105
  • 3
  • 9

1 Answers1

-2

You may change the value to strings rather than array:

curl -X POST http://localhost:8080/job/active-choice-test/buildWithParameters -u abhishek:token --data-urlencode json='{"parameter": [{"name":"state", "value":"Maharashtra"},{"name":"cities", "value":"Mumbai,Pune"}]}'

Floern
  • 33,559
  • 24
  • 104
  • 119
yabo
  • 407
  • 5
  • 6