| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from common.pipeline_wrapper import BasePipeline | 5 from common.pipeline_wrapper import BasePipeline |
| 6 from common.pipeline_wrapper import pipeline | 6 from common.pipeline_wrapper import pipeline |
| 7 from common.waterfall import buildbucket_client | 7 from common.waterfall import buildbucket_client |
| 8 from model.wf_try_job import WfTryJob | 8 from model.wf_try_job import WfTryJob |
| 9 from model.wf_try_job_data import WfTryJobData |
| 9 from waterfall import buildbot | 10 from waterfall import buildbot |
| 10 from waterfall import waterfall_config | 11 from waterfall import waterfall_config |
| 11 from waterfall.try_job_type import TryJobType | 12 from waterfall.try_job_type import TryJobType |
| 12 | 13 |
| 13 | 14 |
| 14 class ScheduleTryJobPipeline(BasePipeline): | 15 class ScheduleTryJobPipeline(BasePipeline): |
| 15 """A pipeline for scheduling a new try job for current build.""" | 16 """A pipeline for scheduling a new try job for current build.""" |
| 16 | 17 |
| 17 def _GetBuildProperties( | 18 def _GetBuildProperties( |
| 18 self, master_name, builder_name, build_number, good_revision, | 19 self, master_name, builder_name, build_number, good_revision, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 56 |
| 56 try_job = buildbucket_client.TryJob( | 57 try_job = buildbucket_client.TryJob( |
| 57 tryserver_mastername, tryserver_buildername, None, properties, []) | 58 tryserver_mastername, tryserver_buildername, None, properties, []) |
| 58 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] | 59 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] |
| 59 | 60 |
| 60 if error: # pragma: no cover | 61 if error: # pragma: no cover |
| 61 raise pipeline.Retry( | 62 raise pipeline.Retry( |
| 62 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) | 63 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) |
| 63 | 64 |
| 64 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) | 65 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) |
| 66 build_id = build.id |
| 67 |
| 65 if try_job_type == TryJobType.COMPILE: | 68 if try_job_type == TryJobType.COMPILE: |
| 66 try_job_result.compile_results.append({'try_job_id': build.id}) | 69 try_job_result.compile_results.append({'try_job_id': build_id}) |
| 67 else: | 70 else: |
| 68 try_job_result.test_results.append({'try_job_id': build.id}) | 71 try_job_result.test_results.append({'try_job_id': build_id}) |
| 69 try_job_result.try_job_ids.append(build.id) | 72 try_job_result.try_job_ids.append(build_id) |
| 70 try_job_result.put() | 73 try_job_result.put() |
| 71 | 74 |
| 72 return build.id | 75 # Create a corresponding WfTryJobData entity to capture as much metadata as |
| 76 # early as possible. |
| 77 try_job_data = WfTryJobData.Create(build_id) |
| 78 try_job_data.master_name = master_name |
| 79 try_job_data.builder_name = builder_name |
| 80 try_job_data.build_number = build_number |
| 81 try_job_data.try_job_type = try_job_type |
| 82 try_job_data.has_compile_targets = bool(compile_targets) |
| 83 try_job_data.has_heuristic_results = bool(suspected_revisions) |
| 84 try_job_data.put() |
| 85 |
| 86 return build_id |
| OLD | NEW |