[英]How to trigger the build of a Jenkins pipeline using REST API with parameters in a POST request?
I made necessary setup to allow a Jenkins pipeline job to be triggered remotely using its REST API.我进行了必要的设置,以允许使用 REST API 远程触发 Jenkins 管道作业。 I'm now testing build trigger using curl.
我现在正在使用 curl 测试构建触发器。
Builds are triggered properly but none of the build parameters are detected.构建被正确触发,但没有检测到任何构建参数。
Build history shows that no parameter passed in POST are detected.构建历史显示未检测到 POST 中传递的参数。 Only those with a default value have it displayed instead of value passed in POST request.
只有那些具有默认值的才会显示它,而不是在 POST 请求中传递的值。
curl -k -X POST https://<Jenkins URL>/job/<my job name>/buildWithParameters?token=XXXXXXXXXXXXXX --user <user>:<API TOKEN> --data-urlencode json='{"parameter": [{"PARAM1": "true"},{"PARAM2": "foo"},{"PARAM3": "X.X.X.X"}]}'
I'm confused because this seemed to be the proper way to trigger a build using Jenkins API.我很困惑,因为这似乎是使用 Jenkins API 触发构建的正确方法。 How to properly trigger a pipeline job using the REST API and POST requests?
如何使用 REST API 和 POST 请求正确触发管道作业?
I found a similar question:我发现了一个类似的问题:
passing parameter to jenkins job through curl POST not working? 通过 curl POST 将参数传递给 jenkins 作业不起作用?
can you try the curl -F
?你能试试
curl -F
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.