def get(self):
    """The get handler method is called from a cron job.

    It expects no parameters and has no output. It checks all current bisect try
    jobs and send comments to an issue on the issue tracker if a bisect job has
    completed.
    """
    issue_tracker = issue_tracker_service.IssueTrackerService(
        utils.ServiceAccountHttp())

    # Set privilege so we can also fetch internal try_job entities.
    datastore_hooks.SetPrivilegedRequest()

    jobs_to_check = try_job.TryJob.query(
        try_job.TryJob.status.IN(['started', 'pending'])).fetch()
    all_successful = True

    for job in jobs_to_check:
      try:
        _CheckJob(job, issue_tracker)
      except Exception as e:  # pylint: disable=broad-except
        logging.error('Caught Exception %s: %s\n%s',
                      type(e).__name__, e, traceback.format_exc())
        all_successful = False

    if all_successful:
      utils.TickMonitoringCustomMetric('UpdateBugWithResults')
コード例 #2
0
 def MakeRequest(self, path, *args, **kwargs):
     """Makes a request to the Rietveld server."""
     if self.internal_only:
         server_url = self.Config().internal_server_url
     else:
         server_url = self.Config().server_url
     url = '%s/%s' % (server_url, path)
     response, content = utils.ServiceAccountHttp().request(
         url, *args, **kwargs)
     return ResponseObject(response.get('status'), content)
def PutJob(job, bucket=_BUCKET_NAME):
    """Creates a job via buildbucket's API."""
    parameters = job.GetBuildParameters()
    service = _DiscoverService(utils.ServiceAccountHttp())
    request = service.put(body={
        'bucket': bucket,
        'parameters_json': json.dumps(parameters),
    })
    response_content = request.execute()
    job.response_fields = response_content.get('build')
    return job.response_fields.get('id')
コード例 #4
0
    def _CommentOnRecoveredBug(cls, bug_id):
        """Adds a comment and close the bug on Issue tracker."""
        bug = ndb.Key('Bug', bug_id).get()
        if bug.status != bug_data.BUG_STATUS_OPENED:
            return
        bug.status = bug_data.BUG_STATUS_RECOVERED
        bug.put()
        comment = cls._RecoveredBugComment(bug_id)

        issue_tracker = issue_tracker_service.IssueTrackerService(
            utils.ServiceAccountHttp())
        issue_tracker.AddBugComment(bug_id, comment)
コード例 #5
0
def PerformBisect(bisect_job):
    """Starts the bisect job.

  This creates a patch, uploads it, then tells Rietveld to try the patch.

  TODO(qyearsley): If we want to use other tryservers sometimes in the future,
  then we need to have some way to decide which one to use. This could
  perhaps be passed as part of the bisect bot name, or guessed from the bisect
  bot name.

  Args:
    bisect_job: A TryJob entity.

  Returns:
    A dictionary containing the result; if successful, this dictionary contains
    the field "issue_id" and "issue_url", otherwise it contains "error".

  Raises:
    AssertionError: Bot or config not set as expected.
    request_handler.InvalidInputError: Some property of the bisect job
        is invalid.
  """
    assert bisect_job.bot and bisect_job.config
    if not bisect_job.key:
        bisect_job.put()

    result = _PerformBuildbucketBisect(bisect_job)
    if 'error' in result:
        bisect_job.run_count += 1
        bisect_job.SetFailed()
        comment = 'Bisect job failed to kick off'
    elif result.get('issue_url'):
        comment = 'Started bisect job %s' % result['issue_url']
    else:
        comment = 'Started bisect job: %s' % result
    if bisect_job.bug_id:
        issue_tracker = issue_tracker_service.IssueTrackerService(
            utils.ServiceAccountHttp())
        issue_tracker.AddBugComment(bisect_job.bug_id,
                                    comment,
                                    send_email=False)
    return result
def GetJobStatus(job_id):
    """Gets the details of a job via buildbucket's API."""
    service = _DiscoverService(utils.ServiceAccountHttp())
    request = service.get(id=job_id)
    response_content = request.execute()
    return response_content
コード例 #7
0
def _DiscoverService():
    return discovery.build('swarming',
                           'v1',
                           discoveryServiceUrl=_DISCOVERY_URL,
                           http=utils.ServiceAccountHttp())