How to pass an array to a jenkins parameterized job via remote access api?

你说的曾经没有我的故事 提交于 2019-12-25 08:41:55

问题


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:

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:

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?


回答1:


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"}]}'



来源:https://stackoverflow.com/questions/43140797/how-to-pass-an-array-to-a-jenkins-parameterized-job-via-remote-access-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!