【问题标题】:How to pass an array to a jenkins parameterized job via remote access api?如何通过远程访问 api 将数组传递给 jenkins 参数化作业?
【发布时间】:2017-03-31 12:33:19
【问题描述】:

我正在尝试使用 curl 命令调用 Jenkins 参数化作业。我正在关注Remote API Jenkins

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

这是作业的截图:

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

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 数组的城市参数。上面的脚本出错了。

我正在打印这样的州和城市变量:

作业正在执行并显示城市错误:

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 参数化作业?

【问题讨论】:

    标签: json curl jenkins jenkins-plugins jenkins-cli


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 2018-05-03
      • 2021-01-21
      • 2018-08-05
      • 2012-02-29
      相关资源
      最近更新 更多