Skip to content

Commit 8e7a727

Browse files
authored
fix(2882): Update build status with k8s hostname together (#457)
1 parent 48511e8 commit 8e7a727

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

screwdriver/screwdriver.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,15 @@ func New(url, token string) (API, error) {
106106
type BuildStatusPayload struct {
107107
Status string `json:"status"`
108108
Meta map[string]interface{} `json:"meta"`
109+
Stats map[string]interface{} `json:"stats"`
109110
}
110111

111112
// BuildStatusMessagePayload is a Screwdriver Build Status Message payload.
112113
type BuildStatusMessagePayload struct {
113114
Status string `json:"status"`
114115
Meta map[string]interface{} `json:"meta"`
115116
StatusMessage string `json:"statusMessage"`
117+
Stats map[string]interface{} `json:"stats"`
116118
}
117119

118120
// StepStartPayload is a Screwdriver Step Start payload.
@@ -439,18 +441,27 @@ func (a api) UpdateBuildStatus(status BuildStatus, meta map[string]interface{},
439441
return fmt.Errorf("creating url: %v", err)
440442
}
441443

444+
stats := map[string]interface{}{}
445+
nodeId := os.Getenv("NODE_ID")
446+
447+
if nodeId != "" {
448+
stats["hostname"] = nodeId
449+
}
450+
442451
var payload []byte
443452
if statusMessage != "" {
444453
bs := BuildStatusMessagePayload{
445454
Status: status.String(),
446455
Meta: meta,
447456
StatusMessage: statusMessage,
457+
Stats: stats,
448458
}
449459
payload, err = json.Marshal(bs)
450460
} else {
451461
bs := BuildStatusPayload{
452462
Status: status.String(),
453463
Meta: meta,
464+
Stats: stats,
454465
}
455466
payload, err = json.Marshal(bs)
456467
}

0 commit comments

Comments
 (0)