如何使用Curl发布到configSubmit Jenkins页面

时间:2016-10-26 07:47:45

标签: curl jenkins jetty http-post jenkins-api

我可以用Python做但不能用Curl做...

$ curl -H "Content-Type: application/json; charset=UTF-8" --data-urlencode   \
   '{ "description": "This is a test job.", "displayName": "#30: Success" }' \
   -n http://localhost/job/playground/30/configSubmit


<body><h2>HTTP ERROR 400</h2>
<p>Problem accessing /job/playground/30/configSubmit. Reason:
<pre>    Nothing is submitted</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

1 个答案:

答案 0 :(得分:0)

我为此苦了几个小时。最终,this answer to a similar question令我困惑。

Jenkins似乎期望表单数据中包含一个名为json的字段。最终对我有用的curl命令是

curl -X POST -F 'json={"displayName":"name","description":"a short description"}' \
  http://localhost/job/playground/30/configSubmit