Repository: xanzy/go-gitlab
Pull request #1692 (2023-04-11 21:40:31)

Updated Job event
Added RunnerType, Tags in Runner struct. Added Environment.

Renamed Shared to IsShared to follow the standard guideline.


Patch:
diff --git a/event_webhook_types.go b/event_webhook_types.go
index 5044444..d68dabf 100644
--- a/event_webhook_types.go
+++ b/event_webhook_types.go
@@ -352,9 +352,9 @@ type JobEvent struct {
 	BuildStartedAt      string     `json:"build_started_at"`
 	BuildFinishedAt     string     `json:"build_finished_at"`
 	BuildDuration       float64    `json:"build_duration"`
+	BuildQueuedDuration float64    `json:"build_queued_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"`
@@ -375,11 +375,14 @@ type JobEvent struct {
 	} `json:"commit"`
 	Repository *Repository `json:"repository"`
 	Runner     struct {
-		ID          int    `json:"id"`
-		Active      bool   `json:"active"`
-		Shared      bool   `json:"is_shared"`
-		Description string `json:"description"`
+		ID          int      `json:"id"`
+		Active      bool     `json:"active"`
+		RunnerType  string   `json:"runner_type"`
+		IsShared    bool     `json:"is_shared"`
+		Description string   `json:"description"`
+		Tags        []string `json:"tags"`
 	} `json:"runner"`
+	Environment string `json:"environment"`
 }
 
 // MemberEvent represents a member event.


Test patch:
diff --git a/event_webhook_types_test.go b/event_webhook_types_test.go
index 421e3c6..5cc95d5 100644
--- a/event_webhook_types_test.go
+++ b/event_webhook_types_test.go
@@ -91,9 +91,9 @@ func TestJobEventUnmarshal(t *testing.T) {
 		BuildStartedAt:      "2023-01-10 13:50:05 UTC",
 		BuildFinishedAt:     "2023-01-10 13:50:54 UTC",
 		BuildDuration:       49.503592,
+		BuildQueuedDuration: 0.193009,
 		BuildAllowFailure:   false,
 		BuildFailureReason:  "unknown_failure",
-		BuildQueuedDuration: 0.193009,
 		RetriesCount:        1,
 		PipelineID:          743121198,
 		ProjectID:           31537070,
@@ -135,9 +135,13 @@ func TestJobEventUnmarshal(t *testing.T) {
 	expectedEvent.Commit.FinishedAt = "2022-10-12 08:09:29 UTC"
 
 	expectedEvent.Runner.ID = 12270837
-	expectedEvent.Runner.Active = true
-	expectedEvent.Runner.Shared = true
 	expectedEvent.Runner.Description = "4-blue.shared.runners-manager.gitlab.com/default"
+	expectedEvent.Runner.RunnerType = "instance_type"
+	expectedEvent.Runner.Active = true
+	expectedEvent.Runner.IsShared = true
+	expectedEvent.Runner.Tags = []string{"linux", "docker"}
+
+	expectedEvent.Environment = "staging"
 
 	assert.Equal(t, expectedEvent, *event, "event should be equal to the expected one")
 }
diff --git a/testdata/webhooks/job.json b/testdata/webhooks/job.json
index f954999..7533245 100644
--- a/testdata/webhooks/job.json
+++ b/testdata/webhooks/job.json
@@ -26,17 +26,8 @@
     "active": true,
     "is_shared": true,
     "tags": [
-      "gce",
-      "east-c",
       "linux",
-      "ruby",
-      "mysql",
-      "postgres",
-      "mongo",
-      "git-annex",
-      "shared",
-      "docker",
-      "saas-linux-small-amd64"
+      "docker"
     ]
   },
   "user": {
@@ -68,5 +59,5 @@
     "git_ssh_url": "git@gitlab.com:jsmithy2/release-tools-fake.git",
     "visibility_level": 20
   },
-  "environment": null
+  "environment": "staging"
 }