argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.93k stars 5.46k forks source link

Support GitLab "System Hook" push webhooks #9625

Closed nneul closed 1 year ago

nneul commented 2 years ago

Summary

Currently Argo does not appear to support System Hook (push) sent from gitlab instance - gets a 400 response.

Motivation

This is much easier to configure once centrally on a on-prem/company gitlab instance.

Proposal

Content is very close to that of per-project push web hooks, just needs to handle the additional event type.

Content-Type: application/json
User-Agent: GitLab/15.0.1
X-Gitlab-Event: System Hook
X-Gitlab-Event-UUID: 69c1d327-4c1c-476a-93ac-230f55cbcd4f
{
  "object_kind": "push",
  "event_name": "push",
  "before": "03d992098fa74ad21482b099f5e33488bda0ee30",
  "after": "5d07fa37e72188fbadff09b7355b6e9941c1cb4d",
  "ref": "refs/heads/k8s",
  ...
jeremymv2 commented 2 years ago

The X-Gitlab-Event: System Hook does not appear to be supported in the code - only PushEvents and TagEvents types are able to be parsed: https://github.com/argoproj/argo-cd/blob/master/util/webhook/webhook.go#L390

The resulting error: level=info msg="Webhook processing failed: event not defined to be parsed"

The SystemHookEvents event type would need to be added: https://pkg.go.dev/gopkg.in/go-playground/webhooks.v5@v5.17.0/gitlab#Event

On the surface, adding this event type seems fairly trivial. A very similar problem existed for Bitbucket webhooks and the DiagnosticsPingEvent type. It was solved in this PR: https://github.com/argoproj/argo-cd/pull/6034/files

By taking the same approach, this line would need to be changed to include , gitlab.SystemHookEvents) and a test added.

Maltazar commented 1 year ago

I would love this event to - it will help so much in development, because we can set it on the whole server instead of on each project/repo.

sentoz commented 1 year ago

Friends, tell me, will there be movement on this issue?