[英]How to Configure Gerrit Webhooks for gerrit events
I am trying to perform some actions on gerrit events我正在尝试对 gerrit 事件执行一些操作
The idea is to get event on API endpoint when any of the above happens in any repository.这个想法是在任何存储库中发生上述任何情况时在 API 端点上获取事件。
I have gerrit 3.1.3 installation running on Amazon Linux ec2 instance, and a node server (with open API endpoints) on another similar EC2 Machine.我在 Amazon Linux ec2 实例上运行了 gerrit 3.1.3 安装,并且在另一台类似的 EC2 机器上运行了一个节点服务器(具有开放的 API 端点)。 In gerrit config I have added the following lines:在 gerrit 配置中,我添加了以下几行:
[plugin "webhooks"]
connectionTimeout = 3000
socketTimeout = 2500
maxTries = 300
retryInterval = 2000
threadPoolSize = 3
[remote "wh_projectCreated"]
url = http://17.233.138.23:8080/gereve
maxTries = 1
sslVerify = false
event = patchset-created
I have checked webhooks
and hooks
plugins are both installed in gerrit installation.我检查了webhooks
和hooks
插件都安装在 gerrit 安装中。 Now, I couldn't find a proper blog post which tells how to configure and get gerrit events to be received on webhooks.现在,我找不到合适的博客文章来说明如何配置和获取要在 webhook 上接收的 gerrit 事件。
What do I need to do more, great help!我还需要做什么,大有帮助!
You can send a PUT HTTP request to update the webhooks.config file:您可以发送 PUT HTTP 请求来更新 webhooks.config 文件:
curl --location --request PUT '[Gerrit-Site]/a/config/server/webhooks~projects/All-Projects/remotes/[Remote-Name]' \
--header 'Content-Type: application/json; charset=UTF-8' \
--header 'Authorization: Basic aWR...' \
--data-raw '{
"url" : "https://adbf...43.ngrok.io/api/v1/webhook/e527d4d7-49e5-4699-b780-5b5c8420dc0f",
"max_tries" : 3,
"ssl_verify": false,
"connection_timeout": 10000
References:参考:
Found the solution, will write down precisely:找到了解决办法,会准确地写下:
All-Projects
repo (with admin url).在文件夹中克隆All-Projects
存储库(使用管理员 URL)。 git clone "http://admin@<gerrit-address>-:<gerrit-port>/a/All-Projects"
. git clone "http://admin@<gerrit-address>-:<gerrit-port>/a/All-Projects"
。cd All-Projects/
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
git checkout meta/config
All-Projects
, create a file named webhooks.config
.在目录All-Projects
的根目录下,创建一个名为webhooks.config
的文件。[remote "changemerged"]
url = http://<webhook-api>:8081/change-merged
event = change-merged
[remote "project_created"]
url = http://<webhook-api>:8081/create-jenkins-project
event = project-created
see gerrit-events .请参阅gerrit 事件。
Add and commit the change: git commit -am "Add webhooks config file"
添加并提交更改: git commit -am "Add webhooks config file"
And check in git push origin meta/config:meta/config
并检查git push origin meta/config:meta/config
and that's it we are done!就是这样,我们完成了!
(Upvote if you found this helpful) (如果觉得有帮助,请点赞)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.