diff --git a/gitlab/gitlab.go b/gitlab/gitlab.go index f414304..8e33406 100644 --- a/gitlab/gitlab.go +++ b/gitlab/gitlab.go @@ -31,14 +31,12 @@ const ( MergeRequestEvents Event = "Merge Request Hook" WikiPageEvents Event = "Wiki Page Hook" PipelineEvents Event = "Pipeline Hook" - BuildEvents Event = "Build Hook" JobEvents Event = "Job Hook" SystemHookEvents Event = "System Hook" objectPush string = "push" objectTag string = "tag_push" objectMergeRequest string = "merge_request" - objectBuild string = "build" ) // Option is a configuration option for the webhook @@ -169,19 +167,12 @@ func eventParsing(gitLabEvent Event, events []Event, payload []byte) (interface{ err := json.Unmarshal([]byte(payload), &pl) return pl, err - case BuildEvents: - var pl BuildEventPayload - err := json.Unmarshal([]byte(payload), &pl) - return pl, err case JobEvents: var pl JobEventPayload err := json.Unmarshal([]byte(payload), &pl) if err != nil { return nil, err } - if pl.ObjectKind == objectBuild { - return eventParsing(BuildEvents, events, payload) - } return pl, nil case SystemHookEvents: diff --git a/gitlab/gitlab_test.go b/gitlab/gitlab_test.go index 22de02a..d3435f7 100644 --- a/gitlab/gitlab_test.go +++ b/gitlab/gitlab_test.go @@ -222,15 +222,6 @@ func TestWebhooks(t *testing.T) { "X-Gitlab-Event": []string{"Pipeline Hook"}, }, }, - { - name: "BuildEvent", - event: BuildEvents, - typ: BuildEventPayload{}, - filename: "../testdata/gitlab/build-event.json", - headers: http.Header{ - "X-Gitlab-Event": []string{"Build Hook"}, - }, - }, } for _, tt := range tests { @@ -276,9 +267,9 @@ func TestJobHooks(t *testing.T) { }{ { name: "JobEvent", - events: []Event{JobEvents, BuildEvents}, - typ: BuildEventPayload{}, - filename: "../testdata/gitlab/build-event.json", + events: []Event{JobEvents}, + typ: JobEventPayload{}, + filename: "../testdata/gitlab/job-event.json", headers: http.Header{ "X-Gitlab-Event": []string{"Job Hook"}, }, diff --git a/gitlab/payload.go b/gitlab/payload.go index 66291a0..adeb81e 100644 --- a/gitlab/payload.go +++ b/gitlab/payload.go @@ -131,29 +131,6 @@ type CommentEventPayload struct { Snippet Snippet `json:"snippet"` } -// BuildEventPayload contains the information for GitLab's build status change event -type BuildEventPayload struct { - ObjectKind string `json:"object_kind"` - Ref string `json:"ref"` - Tag bool `json:"tag"` - BeforeSHA string `json:"before_sha"` - SHA string `json:"sha"` - BuildID int64 `json:"build_id"` - BuildName string `json:"build_name"` - BuildStage string `json:"build_stage"` - BuildStatus string `json:"build_status"` - BuildStartedAt customTime `json:"build_started_at"` - BuildFinishedAt customTime `json:"build_finished_at"` - BuildDuration float64 `json:"build_duration"` - BuildAllowFailure bool `json:"build_allow_failure"` - ProjectID int64 `json:"project_id"` - ProjectName string `json:"project_name"` - User User `json:"user"` - Commit BuildCommit `json:"commit"` - Repository Repository `json:"repository"` - Runner Runner `json:"runner"` -} - // JobEventPayload contains the information for GitLab's Job status change type JobEventPayload struct { ObjectKind string `json:"object_kind"` diff --git a/testdata/gitlab/build-event.json b/testdata/gitlab/build-event.json deleted file mode 100644 index 7fd3084..0000000 --- a/testdata/gitlab/build-event.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "object_kind": "build", - "ref": "gitlab-script-trigger", - "tag": false, - "before_sha": "2293ada6b400935a1378653304eaf6221e0fdb8f", - "sha": "2293ada6b400935a1378653304eaf6221e0fdb8f", - "build_id": 1977, - "build_name": "test", - "build_stage": "test", - "build_status": "created", - "build_started_at": null, - "build_finished_at": null, - "build_duration": null, - "build_allow_failure": false, - "project_id": 380, - "project_name": "gitlab-org/gitlab-test", - "user": { - "id": 3, - "name": "User", - "email": "user@gitlab.com" - }, - "commit": { - "id": 2366, - "sha": "2293ada6b400935a1378653304eaf6221e0fdb8f", - "message": "test\n", - "author_name": "User", - "author_email": "user@gitlab.com", - "status": "created", - "duration": null, - "started_at": null, - "finished_at": null - }, - "repository": { - "name": "gitlab_test", - "git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git", - "description": "Atque in sunt eos similique dolores voluptatem.", - "homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test", - "git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git", - "git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git", - "visibility_level": 20 - } -} \ No newline at end of file