Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove build events, since they don't exist in newer GitLab versions #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 3 additions & 12 deletions gitlab/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"},
},
Expand Down
23 changes: 0 additions & 23 deletions gitlab/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
42 changes: 0 additions & 42 deletions testdata/gitlab/build-event.json

This file was deleted.