gitea icon indicating copy to clipboard operation
gitea copied to clipboard

`push` webhook doesn't fire when pull request is merged

Open berwyn opened this issue 3 years ago • 5 comments

Description

I have a sever with Drone and Gitea setup where I want to run steps every time a PR is merged. Drone ignores the PR closed/merged action, so I thought to filter by pushes to main, however Gitea doesn't dispatch a push event when I merge my PRs (configured as rebase then fast-forward).

Since I cannot find any documentation that lays out what events are pushed and when, I have to assume it's a bug that no push webhook is fired when new commits are pushed to a ref using a PR.

Gitea Version

1.17.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

gitea/gitea:1.17-rootless with docker-compose, docker-ce 20.10.18 running on Ubuntu 22.04

Database

PostgreSQL

berwyn avatar Sep 09 '22 20:09 berwyn

I can confim we have the same issue after we upgraded our Gitea from 1.16 to 1.17. Here are the version with the issue: Drone Server: drone/drone:2.9.1 Gitea: 1.17.0 Manually 'Test Delivery' from Gitea does fire the webhook but not from 'push'.

Also Tested: I can confirm the issue was not there for 1.16.9. Can folks please check which of these New Features/Setting change needs to be configured to get this working: https://blog.gitea.io/2022/07/gitea-1.17.0-is-released/#:~:text=Gitea%201.17%20lays%20the%20foundation,avatar%20can%20now%20be%20communicated.

My hunch is its this change: https://blog.gitea.io/2022/07/gitea-1.17.0-is-released/#-change-initial-trust-model-to-committer-18335httpsgithubcomgo-giteagiteapull18335 (Change initial trust model to committer ) Can someone test please.

jerry3k avatar Sep 10 '22 12:09 jerry3k

Push events never fire for me either. I tested creating commits directory to a monitored branch and merging a pull request. Gitea 1.17.2 Woodpecker 0.15.4

In the Monitoring tab, the GET /user/events seems stuck

image

exu-g avatar Sep 11 '22 18:09 exu-g

Creating a tag doesn't fire events (Create in webhook) either, with /user/events being stuck.

exu-g avatar Sep 12 '22 17:09 exu-g

@jerry3k @RealStickman Did you fix it please?

xtulnx avatar Sep 16 '22 08:09 xtulnx

@xtulnx no fix available as of yet.

jerry3k avatar Sep 16 '22 11:09 jerry3k

webhook is unrelated with /user/events which is just related with notification UI. Could you find the webhook record in history?

lunny avatar Sep 19 '22 09:09 lunny

@jerry3k @RealStickman hi, I temporarily solved the problem of service exception by downgrading.

  1. Stop the service. Back up your data if necessary

  2. Git Image tag use 1.16.9: "gitea/gitea:1.16.9"

  3. Delete the record with type=9 in the repo_unit table (Database):

    delete from repo_unit where `type`=9;
    
  4. Modify version=211 in the version table:

    update version set version=211 where version>211
    

Downgraded 1.17.2 and 1.18.0-dev successfully.

Now my webhook and the latest activity in the homepage are back to normal

xtulnx avatar Sep 20 '22 04:09 xtulnx

@jerry3k @RealStickman hi, I temporarily solved the problem of service exception by downgrading.

  1. Stop the service. Back up your data if necessary
  2. Git Image tag use 1.16.9: "gitea/gitea:1.16.9"
  3. ...
  4. Modify version=211 ... Downgraded 1.17.2 and 1.18.0-dev successfully.

Now my webhook and the latest activity in the homepage are back to normal

Please do NOT do this, as you will be UNABLE to upgrade it in future!

jerry3k avatar Sep 21 '22 14:09 jerry3k

I just setup a Gitea 1.17.2 (docker/docker-rootless) locally and did a full test, all work as expected.

If there is a problem, there are only a few possibilities:

  1. The docker server (not client!) version is too low: make sure >=20.10.6
  2. The git hooks are out of sync: "Resynchronize pre-receive, update and post-receive hooks of all repositories" on the site admin panel
  3. The git repositories (and hooks) are stored on some filesystems(Windows/NAS) which don't support script execution, which is pretty a rare case.

(off topic: /user/events is designed to block for long time for long-polling, it's not related. And DO NOT downgrade by changing the version value in database manually if you are not an experienced Gitea developer)

If you think you encounter a bug, it needs more information to debug. It would be very helpful to provide a reproducible setup (docker-compose config and steps)


The details about push event and webhook:

client git push -> ssh server -> gitea serv sub-command -> git operation -> git hook runs scripts in the repository on the server -> gitea hook sub-command calls the internal HTTP api -> gitea web gets the push event -> insert into database (show activity on the dashboard) -> trigger webhook.

gitea online editor -> git operation -> git hook -> (the same as above).


Test Result

Docker (root)

image

Docker (rootless, merge PR with rebase)

image

wxiaoguang avatar Sep 28 '22 12:09 wxiaoguang

@wxiaoguang Thanks for the detailed reply.
I can confirm storing stuff on a samba share was the issue for me. Local storage works.
Guess I'll have to use that going forward for gitea.

exu-g avatar Sep 28 '22 18:09 exu-g

I still don't understand how docker version affects this, is it possible to somehow fix this without touching docker? I really dont wanna touch docker on production server ....

kSandr-ki avatar Apr 17 '23 14:04 kSandr-ki

Because it's a Docker's bug:

  • https://github.com/go-gitea/gitea/issues/20103#issuecomment-1166268520
  • https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0

wxiaoguang avatar Apr 17 '23 14:04 wxiaoguang

thanks

kSandr-ki avatar Apr 18 '23 12:04 kSandr-ki