Help on webhooks plugin

352 views
Skip to first unread message

ravirajk...@gmail.com

unread,
Dec 14, 2022, 2:53:42 AM12/14/22
to Repo and Gerrit Discussion
Dear community members,

I want to understand about the Gerrit webhooks plugin [1].
I want to achieve a Jenkins job to run on a patchset-created or a ref-updated event on a particular set of repos.

I have installed the plugin and configured it on my dev instance. As described in the plugin documentation, I have added the following in the gerrit.config

[plugin "webhooks"]
  connectionTimeout = 3000
  socketTimeout = 2500
  maxTries = 10
  retryInterval = 2000
  threadPoolSize = 3

And in one of my parent repository, I have created a file webhooks.config in refs/meta/config branch with the below content:

[remote "jenkins"]
  url = http://<user>:<token>@<JENKINS_URL>/job/webhooks-trial/build?token=webhook
  event = patchset-created
  event = ref-updated
  maxTries = 3
  sslVerify = false

I see that my Jenkins job is not triggered on the events.
Here is what I see in the error_log:

[2022-12-14 13:16:22,570] [webhooks-1] DEBUG com.googlesource.gerrit.plugins.webhooks.PostTask : Retrying Processing event: ref-updated for project: PlaygroundAccessControl for remote: http://<user>:<token>@<JENKINS_URL>/job/webhooks-trial/build?token=webhook in 2000ms. Reason: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403 No valid crumb was included in the request</h2>
<table>
<tr><th>URI:</th><td>/job/SCM/job/webhooks-trial/build</td></tr>
<tr><th>STATUS:</th><td>403</td></tr>
<tr><th>MESSAGE:</th><td>No valid crumb was included in the request</td></tr>
<tr><th>SERVLET:</th><td>Stapler</td></tr>
</table>
<hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.30.v20200611</a><hr/>

</body>
</html>

[CONTEXT PLUGIN="gerrit" PLUGIN="webhooks" SUBMISSION_ID="373876-1671003980481-cf3f4897" ]

from the error it looks like it is not using the user name and token provided in the URL. But I do not see a config value to set a user name/token for triggering the remote URL.
Please guide me on how to get it working.





Fabio Ponciroli

unread,
Dec 14, 2022, 4:03:45 AM12/14/22
to ravirajk...@gmail.com, Repo and Gerrit Discussion
Hi,


from the error it looks like it is not using the user name and token provided in the URL. But I do not see a config value to set a user name/token for triggering the remote URL.
Please guide me on how to get it working.





--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/7677f12c-b360-4834-9abd-93f6bc601944n%40googlegroups.com.

ravirajk...@gmail.com

unread,
Dec 14, 2022, 4:40:55 AM12/14/22
to Repo and Gerrit Discussion
  Hi,
I see that it is because of invalid crumb. It is explained here [3]
I am able to run the equivalent curl command from the Gerrit instance and my Jenkins job is triggered. [Both the below work]
 curl -X POST http://<user>:<API token>@<JENKINS_URL>/job/webhooks-trial/build?token=webhook
 curl -X POST -u<user>:<API token>  <JENKINS_URL>/job/webhooks-trial/build?token=webhook
This makes me wonder if the plugin is expecting the user name and api token to be provided with some other configuration and not embedded in URL.

[3] https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/client-and-managed-masters/csrf-protection-explained


  [1]: https://stackoverflow.com/questions/44711696/jenkins-403-no-valid-crumb-was-included-in-the-request
   

  from the error it looks like it is not using the user name and token provided in the URL. But I do not see a config value to set a user name/token for triggering the remote URL.
  Please guide me on how to get it working.




  [1] https://gerrit.googlesource.com/plugins/webhooks/+/refs/heads/stable-2.16/src/main/resources/Documentation/config.md

Matthias Sohn

unread,
Dec 14, 2022, 4:43:49 AM12/14/22
to Fabio Ponciroli, ravirajk...@gmail.com, Repo and Gerrit Discussion
On Wed, Dec 14, 2022 at 10:03 AM Fabio Ponciroli <pon...@gmail.com> wrote:
Hi,

Il giorno mer 14 dic 2022 alle ore 08:53 ravirajk...@gmail.com <ravirajk...@gmail.com> ha scritto:
Dear community members,

I want to understand about the Gerrit webhooks plugin [1].
I want to achieve a Jenkins job to run on a patchset-created or a ref-updated event on a particular set of repos.

ravirajk...@gmail.com

unread,
Dec 14, 2022, 5:40:48 AM12/14/22
to Repo and Gerrit Discussion
Thanks for the suggestion Matthias.
I wanted to try webhooks because of the reasons below.
gerrit-trigger: I heard it is not maintained any more. No issues using it unless we face an issue.
gerrit-code-review: We need to schedule to poll Gerrit for changes against a branch/repository
vs
webhook: no need to poll gerrit thus saving unnecessary requests to Gerrit.
Reply all
Reply to author
Forward
0 new messages