通过 Web API 设置 Hudson 构建描述
我有一个在 Hudson 构建上运行的 Python 脚本,并且希望能够以编程方式设置构建的描述。
我可以在构建页面上单击“添加描述”并填写表单,如何将一些数据 POST 到与表单相同的 URL?
I have a Python script that operates on Hudson builds and would love to be able to set the description of a build programmatically.
I can click "Add Description" on a build's page and fill in the form, how can I POST some data to the same URL that form does?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
弄清楚了,需要将以下内容作为表单数据(内容类型
application/x-www-form-urlencoded
)发布到http://myserver/hudson/job/thebuild/10/submitDescription
在代码中:
Figured it out, need to POST the following as form data (content type
application/x-www-form-urlencoded
) tohttp://myserver/hudson/job/thebuild/10/submitDescription
In code:
(会发表评论,但没有足够的代表)
感谢 jtb 提供的大部分方法。如果服务器上启用了安全性,我发现我可以使用此代码进行身份验证(改编自 此处)
用户和令牌的值可以在 API 令牌下找到:
http:///me/configure
(would comment, but not enough rep)
Thanks to jtb for the bulk of the approach. If security is enabled on the server, I found that I could authenticate using this code (adapted from here)
The values for user and token can be found under API Token in:
http://<myserver>/me/configure
使用“执行系统 Groovy 脚本”构建任务:
Using an 'Execute system Groovy script' Build task:
这是在 shell 中运行良好的curl 命令。替换之间的文本(包括 {})。
curl -X POST -u {用户:密码} -H '内容类型:application/x-www-form-urlencoded' --data-urlencode 描述={描述字符串} {hudsonurl}/job/{jobname}/{buildnumber }/提交描述
Here is the curl command that worked fine from shell. Replace the text in between and including {}.
curl -X POST -u {user:password} -H 'Content-Type: application/x-www-form-urlencoded' --data-urlencode description={descriptionstring} {hudsonurl}/job/{jobname}/{buildnumber}/submitDescription