diff --git a/util/webhook/webhook.go b/util/webhook/webhook.go index b5b14c3e7d646..c47323f2cdbbb 100644 --- a/util/webhook/webhook.go +++ b/util/webhook/webhook.go @@ -441,7 +441,7 @@ func (a *ArgoCDWebhookHandler) Handler(w http.ResponseWriter, r *http.Request) { log.WithField(common.SecurityField, common.SecurityHigh).Infof("GitHub webhook HMAC verification failed") } case r.Header.Get("X-Gitlab-Event") != "": - payload, err = a.gitlab.Parse(r, gitlab.PushEvents, gitlab.TagEvents) + payload, err = a.gitlab.Parse(r, gitlab.PushEvents, gitlab.TagEvents, gitlab.SystemHookEvents) if errors.Is(err, gitlab.ErrGitLabTokenVerificationFailed) { log.WithField(common.SecurityField, common.SecurityHigh).Infof("GitLab webhook token verification failed") } diff --git a/util/webhook/webhook_test.go b/util/webhook/webhook_test.go index efd68fe25b9b9..899c3ecb73203 100644 --- a/util/webhook/webhook_test.go +++ b/util/webhook/webhook_test.go @@ -336,6 +336,22 @@ func TestGitLabPushEvent(t *testing.T) { hook.Reset() } +func TestGitLabSystemEvent(t *testing.T) { + hook := test.NewGlobal() + h := NewMockHandler(nil, []string{}) + req := httptest.NewRequest(http.MethodPost, "/api/webhook", nil) + req.Header.Set("X-Gitlab-Event", "System Hook") + eventJSON, err := os.ReadFile("testdata/gitlab-event.json") + assert.NoError(t, err) + req.Body = io.NopCloser(bytes.NewReader(eventJSON)) + w := httptest.NewRecorder() + h.Handler(w, req) + assert.Equal(t, w.Code, http.StatusOK) + expectedLogResult := "Received push event repo: https://gitlab/group/name, revision: master, touchedHead: true" + assert.Equal(t, expectedLogResult, hook.LastEntry().Message) + hook.Reset() +} + func TestInvalidMethod(t *testing.T) { hook := test.NewGlobal() h := NewMockHandler(nil, []string{})