diff --git a/pkg/gcp/gcb/history.go b/pkg/gcp/gcb/history.go index 34cff6e9448..9e7c7d66c3e 100644 --- a/pkg/gcp/gcb/history.go +++ b/pkg/gcp/gcb/history.go @@ -154,6 +154,11 @@ func (h *History) Run() error { end := job.Timing["BUILD"].EndTime logs := job.LogUrl + if start == "" || end == "" { + logrus.Infof("Skipping unfinished job from %s with ID: %s", job.CreateTime, job.Id) + continue + } + // Calculate the duration of the job const layout = "2006-01-02T15:04:05.99Z" tStart, err := h.impl.ParseTime(layout, start) diff --git a/pkg/gcp/gcb/history_test.go b/pkg/gcp/gcb/history_test.go index f7eb7596383..0dc3460dee0 100644 --- a/pkg/gcp/gcb/history_test.go +++ b/pkg/gcp/gcb/history_test.go @@ -104,7 +104,10 @@ func TestHistoryRun(t *testing.T) { { Tags: []string{"RELEASE"}, Timing: map[string]cloudbuild.TimeSpan{ - "BUILD": {StartTime: "wrong"}, + "BUILD": { + StartTime: "wrong", + EndTime: "2020-10-10", + }, }, }, }, nil) @@ -121,7 +124,10 @@ func TestHistoryRun(t *testing.T) { { Tags: []string{"STAGE"}, Timing: map[string]cloudbuild.TimeSpan{ - "BUILD": {EndTime: "wrong"}, + "BUILD": { + StartTime: "2020-10-10", + EndTime: "wrong", + }, }, Substitutions: map[string]string{"_NOMOCK": "true"}, },