Configuring webhooks in Jenkins #1653

Closed
opened 2025-11-02 04:08:30 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @lfdmn on GitHub (Mar 27, 2018).

  • Gitea version (or commit ref): 1.4.0+rc2-2-g92a3061
  • Git version: 2.7.4
  • Operating system: linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Hi,

I'm trying to trigger a freestyle project build from gitea webhooks.

I have:
Gitea at https://my.domain.ltd/gitea/
Jenkins at https://my.domain.ltd/jenkins

In gitea I have created a test project with a README.md file that I update. On that project I went to Settings > Webhooks:

I have logged in linux with my jenkins user, created an ssh key, added it to gitea and cloned a repository to add the gitea host to the known_hosts.

Then I created a test_hooks freestyle project with:

  • Project name: test_hooks
  • Source Code Management > Git
    • Repositories:
      • url: ssh://my.domain.ltd:2222/user.name/test_hooks.git
      • Credentials: - none - (since I have install my keys for jenkins user)
    • Branches to build: master
    • Repository browser: Gitea | repository URL: https://my.domain.ltd/gitea/user.name/test_hooks
  • Build Triggers
    • Poll SCM: checked
      • Schedule: left blank since the doc says "No schedules so will only run due to SCM changes if triggered by a post-commit hook"
  • Build
    • Execute shell
      • Command: cat README.md

The job manually builds.

In Gitea test_hooks project > Settings > Webhooks I click Test Delivery and Gitea reports it was delivered properly.

In jenkins.branch.OrganizationFolder.log and jenkins.branch.MultiBranchProject.log I can see:
[Mon Mar 26 16:46:34 EEST 2018] Finished processing Push event to branch master in repository user.name/test_hooks UPDATED event from 127.0.0.1 ⇒ https://my.domain.ltd/jenkins/gitea-webhook/post with timestamp Mon Mar 26 16:46:34 EEST 2018. **Matched 0**.

So Jenkins do get the POST event but there is no match: Matched 0

Do I get it wrong? How can I trigger my job? Is there a way to debug the JSON POST data?

Thanks,
-Damien

Originally created by @lfdmn on GitHub (Mar 27, 2018). - Gitea version (or commit ref): 1.4.0+rc2-2-g92a3061 - Git version: 2.7.4 - Operating system: linux - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant Hi, I'm trying to trigger a freestyle project build from gitea webhooks. I have: Gitea at https://my.domain.ltd/gitea/ Jenkins at https://my.domain.ltd/jenkins In gitea I have created a test project with a README.md file that I update. On that project I went to Settings > Webhooks: * Payload URL: https://my.domain.ltd/jenkins/gitea-webhook/post * Content type: application/json * Secret: blank * When should this webhook be triggered? Just the push event * Active: checked I have logged in linux with my jenkins user, created an ssh key, added it to gitea and cloned a repository to add the gitea host to the known_hosts. Then I created a test_hooks freestyle project with: * Project name: test_hooks * Source Code Management > Git * Repositories: * url: ssh://my.domain.ltd:2222/user.name/test_hooks.git * Credentials: - none - (since I have install my keys for jenkins user) * Branches to build: master * Repository browser: Gitea | repository URL: https://my.domain.ltd/gitea/user.name/test_hooks * Build Triggers * Poll SCM: checked * Schedule: left blank since the doc says "No schedules so will only run due to SCM changes if triggered by a post-commit hook" * Build * Execute shell * Command: cat README.md The job manually builds. In Gitea test_hooks project > Settings > Webhooks I click Test Delivery and Gitea reports it was delivered properly. In jenkins.branch.OrganizationFolder.log and jenkins.branch.MultiBranchProject.log I can see: `[Mon Mar 26 16:46:34 EEST 2018] Finished processing Push event to branch master in repository user.name/test_hooks UPDATED event from 127.0.0.1 ⇒ https://my.domain.ltd/jenkins/gitea-webhook/post with timestamp Mon Mar 26 16:46:34 EEST 2018. **Matched 0**. ` So Jenkins do get the POST event but there is no match: **Matched 0** Do I get it wrong? How can I trigger my job? Is there a way to debug the JSON POST data? Thanks, -Damien
GiteaMirror added the type/questionissue/stale labels 2025-11-02 04:08:30 -06:00
Author
Owner

@aliechti commented on GitHub (Mar 27, 2018):

Is it possible that the version 1.4.0 doesn't work with the newest Jenkins Gitea plugin?
On our system it doesn't work since we've upgraded.

@aliechti commented on GitHub (Mar 27, 2018): Is it possible that the version 1.4.0 doesn't work with the newest Jenkins Gitea plugin? On our system it doesn't work since we've upgraded.
Author
Owner

@lafriks commented on GitHub (Mar 27, 2018):

Do you get any errors in gitea.log?

@lafriks commented on GitHub (Mar 27, 2018): Do you get any errors in gitea.log?
Author
Owner

@lfdmn commented on GitHub (Mar 28, 2018):

There's no error in gitea.log. Jenkins receives the post message correctly, I don't think this is a Gitea issue unless the post message format changed.

I managed yesterday to build a multi-branch pipeline project. The webhook works there after I figured this out:

  • If you set the owner to a user, like yourself, it is enough for the credentials you use to be administrator for the Gitea repositories and they will be listed in the repository drop down menu.
  • if you set the owner to an organization name, the credentials you use must be gitea system admin. Admin on organization/repositories is not enough, and the list of repositories is empty. Gitea issue or Jenkins plugin issue, I'm not sure.

screenshot from 2018-03-28 10-33-33

Webhooks don't work with single branch pipeline and freestyle projects, but since they use the same post message than the multibranch, I'd say the issue is on the jenkins plugin side.

I'll try to have a look at the plugin source but I'm not familiar with Java environment at all, so I might not be of too much help =)

Gogs plugin still works for freestyle project.

@lfdmn commented on GitHub (Mar 28, 2018): There's no error in gitea.log. Jenkins receives the post message correctly, I don't think this is a Gitea issue unless the post message format changed. I managed yesterday to build a multi-branch pipeline project. The webhook works there after I figured this out: * If you set the owner to a user, like yourself, it is enough for the credentials you use to be administrator for the Gitea repositories and they will be listed in the repository drop down menu. * if you set the owner to an organization name, the credentials you use must be gitea system admin. Admin on organization/repositories is not enough, and the list of repositories is empty. Gitea issue or Jenkins plugin issue, I'm not sure. ![screenshot from 2018-03-28 10-33-33](https://user-images.githubusercontent.com/17184363/38015281-f9892fd6-3273-11e8-8651-a1e3ad63e65a.png) Webhooks don't work with single branch pipeline and freestyle projects, but since they use the same post message than the multibranch, I'd say the issue is on the jenkins plugin side. I'll try to have a look at the plugin source but I'm not familiar with Java environment at all, so I might not be of too much help =) Gogs plugin still works for freestyle project.
Author
Owner

@lafriks commented on GitHub (Mar 28, 2018):

@lafriks commented on GitHub (Mar 28, 2018): ~~~Can you diff gitea and gogs posted messages?~~~ sorry misread
Author
Owner

@lfdmn commented on GitHub (Mar 28, 2018):

Where can I read the messages from?

On Wed, Mar 28, 2018, 20:58 Lauris BH notifications@github.com wrote:

Can you diff gitea and gogs posted messages?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/3724#issuecomment-376978689,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQY2a-ITroven_fajhSXGKeHaPxlp1kuks5ti881gaJpZM4S8YKd
.

@lfdmn commented on GitHub (Mar 28, 2018): Where can I read the messages from? On Wed, Mar 28, 2018, 20:58 Lauris BH <notifications@github.com> wrote: > Can you diff gitea and gogs posted messages? > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/3724#issuecomment-376978689>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AQY2a-ITroven_fajhSXGKeHaPxlp1kuks5ti881gaJpZM4S8YKd> > . >
Author
Owner

@ukos-git commented on GitHub (Aug 31, 2018):

@lfdmn can you give an update upon current progress?

@ukos-git commented on GitHub (Aug 31, 2018): @lfdmn can you give an update upon current progress?
Author
Owner

@canhanhan commented on GitHub (Sep 29, 2018):

@lfdmn you can see the JSON data sent in Gitea. Go to Repository Settings / Web Hooks / Edit Web Hook / Recent Deliveries. Just click one of the guids and it will show you the content that was sent.

I just had a similar issue. In my case; I didn't have base URL configured in Gitea and it was sending URLs in the JSON as "localhost" but I had Jenkins configured with a different domain. I changed ROOT_URL in app.ini to match to Jenkins and it started working.

@canhanhan commented on GitHub (Sep 29, 2018): @lfdmn you can see the JSON data sent in Gitea. Go to Repository Settings / Web Hooks / Edit Web Hook / Recent Deliveries. Just click one of the guids and it will show you the content that was sent. I just had a similar issue. In my case; I didn't have base URL configured in Gitea and it was sending URLs in the JSON as "localhost" but I had Jenkins configured with a different domain. I changed ROOT_URL in app.ini to match to Jenkins and it started working.
Author
Owner

@stale[bot] commented on GitHub (Jan 8, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 8, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@techknowlogick commented on GitHub (Jan 14, 2019):

Closing issue. Please open a post in the forum if this is still an issue.

@techknowlogick commented on GitHub (Jan 14, 2019): Closing issue. Please open a post in the [forum](https://discourse.gitea.io/) if this is still an issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1653