| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Package buildbucket implements tasks that run Buildbucket jobs. | 5 // Package buildbucket implements tasks that run Buildbucket jobs. |
| 6 package buildbucket | 6 package buildbucket |
| 7 | 7 |
| 8 import ( | 8 import ( |
| 9 "encoding/json" | 9 "encoding/json" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 m.handleBuildResult(c, ctl, resp.Build) | 346 m.handleBuildResult(c, ctl, resp.Build) |
| 347 if ctl.State().Status.Final() { | 347 if ctl.State().Status.Final() { |
| 348 ctl.DebugLog("Buildbucket build:\n%s", blob) | 348 ctl.DebugLog("Buildbucket build:\n%s", blob) |
| 349 } | 349 } |
| 350 | 350 |
| 351 return nil | 351 return nil |
| 352 } | 352 } |
| 353 | 353 |
| 354 // handleBuildResult processes buildbucket results message updating the state | 354 // handleBuildResult processes buildbucket results message updating the state |
| 355 // of the invocation. | 355 // of the invocation. |
| 356 func (m TaskManager) handleBuildResult(c context.Context, ctl task.Controller, r
*buildbucket.ApiBuildMessage) { | 356 func (m TaskManager) handleBuildResult(c context.Context, ctl task.Controller, r
*buildbucket.ApiCommonBuildMessage) { |
| 357 ctl.DebugLog( | 357 ctl.DebugLog( |
| 358 "Build %d: status %q, result %q, failure_reason %q, cancelation_
reason %q", | 358 "Build %d: status %q, result %q, failure_reason %q, cancelation_
reason %q", |
| 359 r.Id, r.Status, r.Result, r.FailureReason, r.CancelationReason) | 359 r.Id, r.Status, r.Result, r.FailureReason, r.CancelationReason) |
| 360 switch { | 360 switch { |
| 361 case r.Status == "SCHEDULED" || r.Status == "STARTED": | 361 case r.Status == "SCHEDULED" || r.Status == "STARTED": |
| 362 return // do nothing | 362 return // do nothing |
| 363 case r.Status == "COMPLETED" && r.Result == "SUCCESS": | 363 case r.Status == "COMPLETED" && r.Result == "SUCCESS": |
| 364 ctl.State().Status = task.StatusSucceeded | 364 ctl.State().Status = task.StatusSucceeded |
| 365 default: | 365 default: |
| 366 ctl.State().Status = task.StatusFailed | 366 ctl.State().Status = task.StatusFailed |
| 367 } | 367 } |
| 368 } | 368 } |
| OLD | NEW |