Skip to content

Commit

Permalink
fix(2882): Update build status with k8s hostname together (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-oksaku authored Aug 17, 2023
1 parent 48511e8 commit 8e7a727
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions screwdriver/screwdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ func New(url, token string) (API, error) {
type BuildStatusPayload struct {
Status string `json:"status"`
Meta map[string]interface{} `json:"meta"`
Stats map[string]interface{} `json:"stats"`
}

// BuildStatusMessagePayload is a Screwdriver Build Status Message payload.
type BuildStatusMessagePayload struct {
Status string `json:"status"`
Meta map[string]interface{} `json:"meta"`
StatusMessage string `json:"statusMessage"`
Stats map[string]interface{} `json:"stats"`
}

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

stats := map[string]interface{}{}
nodeId := os.Getenv("NODE_ID")

if nodeId != "" {
stats["hostname"] = nodeId
}

var payload []byte
if statusMessage != "" {
bs := BuildStatusMessagePayload{
Status: status.String(),
Meta: meta,
StatusMessage: statusMessage,
Stats: stats,
}
payload, err = json.Marshal(bs)
} else {
bs := BuildStatusPayload{
Status: status.String(),
Meta: meta,
Stats: stats,
}
payload, err = json.Marshal(bs)
}
Expand Down

0 comments on commit 8e7a727

Please sign in to comment.