From ec7a8cdff95709d9f38fbcf681edf489e806c8c5 Mon Sep 17 00:00:00 2001 From: vntw Date: Wed, 19 Oct 2022 16:11:26 +0200 Subject: [PATCH 1/2] Add `ref` to deployment webhook This seems to be undocumented but looking at the code always present: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/data_builder/deployment.rb#L44 --- event_webhook_types.go | 1 + event_webhook_types_test.go | 4 ++++ testdata/webhooks/deployment.json | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/event_webhook_types.go b/event_webhook_types.go index cb9432212..222530760 100644 --- a/event_webhook_types.go +++ b/event_webhook_types.go @@ -151,6 +151,7 @@ type DeploymentEvent struct { SSHURL string `json:"ssh_url"` HTTPURL string `json:"http_url"` } `json:"project"` + Ref string `json:"ref"` ShortSHA string `json:"short_sha"` User *EventUser `json:"user"` UserURL string `json:"user_url"` diff --git a/event_webhook_types_test.go b/event_webhook_types_test.go index 7c2d67b3d..e01ff40f6 100644 --- a/event_webhook_types_test.go +++ b/event_webhook_types_test.go @@ -92,6 +92,10 @@ func TestDeploymentEventUnmarshal(t *testing.T) { if event.CommitTitle != "Add new file" { t.Errorf("CommitTitle is %s, want %s", event.CommitTitle, "Add new file") } + + if event.Ref != "1.0.0" { + t.Errorf("Ref is %s, want %s", event.Ref, "1.0.0") + } } func TestIssueCommentEventUnmarshal(t *testing.T) { diff --git a/testdata/webhooks/deployment.json b/testdata/webhooks/deployment.json index 3ab09fd17..ce3c13137 100644 --- a/testdata/webhooks/deployment.json +++ b/testdata/webhooks/deployment.json @@ -32,5 +32,6 @@ }, "user_url": "http://10.126.0.2:3000/root", "commit_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/commit/279484c09fbe69ededfced8c1bb6e6d24616b468", - "commit_title": "Add new file" + "commit_title": "Add new file", + "ref": "1.0.0" } From decc7fee431c75bcd8e6ab18792d164320be224c Mon Sep 17 00:00:00 2001 From: vntw Date: Wed, 19 Oct 2022 16:17:21 +0200 Subject: [PATCH 2/2] Update missing webhook job event docs URL --- event_webhook_types.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/event_webhook_types.go b/event_webhook_types.go index 222530760..e59621314 100644 --- a/event_webhook_types.go +++ b/event_webhook_types.go @@ -306,8 +306,7 @@ type IssueEvent struct { // JobEvent represents a job event. // // GitLab API docs: -// TODO: link to docs instead of src once they are published. -// https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/data_builder/build.rb +// https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html#job-events type JobEvent struct { ObjectKind string `json:"object_kind"` Ref string `json:"ref"`