如何通过远程访问api将数组传递给jenkins参数化作业? [英] How to pass an array to a jenkins parameterized job via remote access api?

查看:224
本文介绍了如何通过远程访问api将数组传递给jenkins参数化作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用curl命令调用Jenkins参数化作业.我正在关注远程API詹金斯.

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

我有Active Choice参数插件.作业的参数之一是主动选择反应参数.

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

这是工作的屏幕截图:

我正在使用以下curl命令通过参数触发它:

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

但是我不能传递应该是json数组的citys参数.上面的脚本给出了错误.

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

请告诉我在使用远程访问API时如何将数组参数传递给jenkins参数化作业?

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

推荐答案

您可以将值更改为字符串而不是数组:

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

这篇关于如何通过远程访问api将数组传递给jenkins参数化作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆