Repository: xanzy/go-gitlab
Pull request #1668 (2023-03-10 14:47:56)

Add BuildQueuedDuration to JobEvent struct
The field is send by GitLab for a while now, the fixtures also already included it so I'm just properly passing it through. GitLabs docs are just outdated.


Patch:
diff --git a/event_webhook_types.go b/event_webhook_types.go
index 8d68279..8b8c519 100644
--- a/event_webhook_types.go
+++ b/event_webhook_types.go
@@ -335,27 +335,28 @@ type IssueEvent struct {
 // GitLab API docs:
 // 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"`
-	Tag                bool       `json:"tag"`
-	BeforeSHA          string     `json:"before_sha"`
-	SHA                string     `json:"sha"`
-	BuildID            int        `json:"build_id"`
-	BuildName          string     `json:"build_name"`
-	BuildStage         string     `json:"build_stage"`
-	BuildStatus        string     `json:"build_status"`
-	BuildCreatedAt     string     `json:"build_created_at"`
-	BuildStartedAt     string     `json:"build_started_at"`
-	BuildFinishedAt    string     `json:"build_finished_at"`
-	BuildDuration      float64    `json:"build_duration"`
-	BuildAllowFailure  bool       `json:"build_allow_failure"`
-	BuildFailureReason string     `json:"build_failure_reason"`
-	RetriesCount       int        `json:"retries_count"`
-	PipelineID         int        `json:"pipeline_id"`
-	ProjectID          int        `json:"project_id"`
-	ProjectName        string     `json:"project_name"`
-	User               *EventUser `json:"user"`
-	Commit             struct {
+	ObjectKind          string     `json:"object_kind"`
+	Ref                 string     `json:"ref"`
+	Tag                 bool       `json:"tag"`
+	BeforeSHA           string     `json:"before_sha"`
+	SHA                 string     `json:"sha"`
+	BuildID             int        `json:"build_id"`
+	BuildName           string     `json:"build_name"`
+	BuildStage          string     `json:"build_stage"`
+	BuildStatus         string     `json:"build_status"`
+	BuildCreatedAt      string     `json:"build_created_at"`
+	BuildStartedAt      string     `json:"build_started_at"`
+	BuildFinishedAt     string     `json:"build_finished_at"`
+	BuildDuration       float64    `json:"build_duration"`
+	BuildAllowFailure   bool       `json:"build_allow_failure"`
+	BuildFailureReason  string     `json:"build_failure_reason"`
+	BuildQueuedDuration float64    `json:"build_queued_duration"`
+	RetriesCount        int        `json:"retries_count"`
+	PipelineID          int        `json:"pipeline_id"`
+	ProjectID           int        `json:"project_id"`
+	ProjectName         string     `json:"project_name"`
+	User                *EventUser `json:"user"`
+	Commit              struct {
 		ID          int    `json:"id"`
 		Name        string `json:"name"`
 		SHA         string `json:"sha"`


Test patch:
diff --git a/event_webhook_types_test.go b/event_webhook_types_test.go
index 6f13596..a3c7a2d 100644
--- a/event_webhook_types_test.go
+++ b/event_webhook_types_test.go
@@ -78,25 +78,26 @@ func TestJobEventUnmarshal(t *testing.T) {
 	}
 
 	expectedEvent := JobEvent{
-		ObjectKind:         "build",
-		Ref:                "main",
-		Tag:                false,
-		BeforeSHA:          "0000000000000000000000000000000000000000",
-		SHA:                "95d49d1efbd941908580e79d65e4b5ecaf4a8305",
-		BuildID:            3580121225,
-		BuildName:          "auto_deploy:start",
-		BuildStage:         "coordinated:tag",
-		BuildStatus:        "success",
-		BuildCreatedAt:     "2023-01-10 13:50:02 UTC",
-		BuildStartedAt:     "2023-01-10 13:50:05 UTC",
-		BuildFinishedAt:    "2023-01-10 13:50:54 UTC",
-		BuildDuration:      49.503592,
-		BuildAllowFailure:  false,
-		BuildFailureReason: "unknown_failure",
-		RetriesCount:       1,
-		PipelineID:         743121198,
-		ProjectID:          31537070,
-		ProjectName:        "John Smith / release-tools-fake",
+		ObjectKind:          "build",
+		Ref:                 "main",
+		Tag:                 false,
+		BeforeSHA:           "0000000000000000000000000000000000000000",
+		SHA:                 "95d49d1efbd941908580e79d65e4b5ecaf4a8305",
+		BuildID:             3580121225,
+		BuildName:           "auto_deploy:start",
+		BuildStage:          "coordinated:tag",
+		BuildStatus:         "success",
+		BuildCreatedAt:      "2023-01-10 13:50:02 UTC",
+		BuildStartedAt:      "2023-01-10 13:50:05 UTC",
+		BuildFinishedAt:     "2023-01-10 13:50:54 UTC",
+		BuildDuration:       49.503592,
+		BuildAllowFailure:   false,
+		BuildFailureReason:  "unknown_failure",
+		BuildQueuedDuration: 0.193009,
+		RetriesCount:        1,
+		PipelineID:          743121198,
+		ProjectID:           31537070,
+		ProjectName:         "John Smith / release-tools-fake",
 		User: &EventUser{
 			ID:        2967854,
 			Name:      "John Smith",