Webhook firing on finished git push event
Summary
We have noticed in our local fork of GitLab CE/EE that a webhook event will fire on previously completed git push event
Steps to reproduce
hook.js Please use my script (add personal access token) with the following sequential workflow:
- create a project
- add a commit via API
- after step 2 finishes, add a webhook onto the project via API
- observe that the webhook has a firing event
Example Project
This issue only happens on a local GitLab server (latest versions of CE/EE) and not reproducible on GitLab.com. Note when I first reported this issue in #30236 (closed), I think I was able to see the same problem on GitLab.com.
What is the current bug behavior?
go to :projectId/hooks/:hookId/edit
and notice a recent delivery due to adding the webhook
What is the expected correct behavior?
no recent delivery
Relevant logs and/or screenshots
Output of checks
This bug doesn't happen on GitLab.com currently
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:env:info
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
)
Results of GitLab application Check
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 10.0.0 ? ... OK (10.0.0)
Running /Users/yuanchenlu/Desktop/gitlab.com/gitlab-development-kit/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.6.3)
Git version >= 2.22.0 ? ... yes (2.23.0)
Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
I have a potential fix with the following logic: In app/models/projects.rb "execute_hooks" : only fire webhook if latest commit happens after webhook is added