コード例 #1
0
ファイル: models.py プロジェクト: AppDevy/cabot
  def run(self):
    start = timezone.now()
    result = StatusCheckResult(
      check=self,
      time=start,
    )
    try:
      status = get_job_status(self.name)
      active = status['active']
    except requests.HTTPError:
      # Fail if there's a 404 - the job is misconfigured probably
      result.error = 'Job %s not found on Jenkins' % self.name
      result.succeeded = False
      finish = timezone.now()
      result.time_complete = finish
      result.save()
      self.last_run = finish
      super(JenkinsStatusCheck, self).save()
      return
    except:
      # If something else goes wrong, we will *not* fail - otherwise
      # a lot of services seem to fail all at once.
      # Ugly to do it here but...
      finish = timezone.now()
      result.error = 'Error fetching from Jenkins'
      result.succeeded = True
      result.time_complete = finish
      result.save()
      self.last_run = finish
      super(JenkinsStatusCheck, self).save()
      return
    if not active:
      # We will fail if the job has been disabled
      result.error = 'Job "%s" disabled on Jenkins' % self.name
      result.succeeded = False
    else:
      if self.max_queued_build_time and status['blocked_build_time']:
        if status['blocked_build_time'] > self.max_queued_build_time*60:
          result.succeeded = False
          result.error = 'Job "%s" has blocked build waiting for %ss (> %sm)' % (
            self.name,
            int(status['blocked_build_time']),
            self.max_queued_build_time
          )
        else:
          result.succeeded = status['succeeded']
      else:
        result.succeeded = status['succeeded']
      if not status['succeeded']:
        if result.error:
          result.error +='; Job "%s" failing on Jenkins' % self.name
        else:
          result.error = 'Job "%s" failing on Jenkins' % self.name
        result.raw_data = status

    finish = timezone.now()
    result.time_complete = finish
    result.save()
    self.last_run = finish
    super(JenkinsStatusCheck, self).save()
コード例 #2
0
ファイル: models.py プロジェクト: arjunmenon/cabot
 def run(self):
   start = timezone.now()
   result = StatusCheckResult(
     check=self,
     time=start,
   )
   try:
     status = get_job_status(self.name)
     active = status['active']
     if status['status_code'] == 404:
       result.error = 'Job %s not found on Jenkins' % self.name
       result.succeeded = False
       finish = timezone.now()
       result.time_complete = finish
       result.save()
       self.last_run = finish
       super(JenkinsStatusCheck, self).save()
       return
     elif status['status_code'] > 400:
       # Will fall through to next block
       raise Exception('returned %s' % status['status_code'])
   except Exception, e:
     # If something else goes wrong, we will *not* fail - otherwise
     # a lot of services seem to fail all at once.
     # Ugly to do it here but...
     finish = timezone.now()
     result.error = 'Error fetching from Jenkins - %s' % e
     result.succeeded = True
     result.time_complete = finish
     result.save()
     self.last_run = finish
     super(JenkinsStatusCheck, self).save()
     return
コード例 #3
0
    def run(self):
        start = timezone.now()
        result = StatusCheckResult(
            check=self,
            time=start,
        )
        try:
            status = get_job_status(self.name)
            active = status['active']
        except requests.HTTPError:
            # Fail if there's a 404 - the job is misconfigured probably
            result.error = 'Job %s not found on Jenkins' % self.name
            result.succeeded = False
            finish = timezone.now()
            result.time_complete = finish
            result.save()
            self.last_run = finish
            super(JenkinsStatusCheck, self).save()
            return
        except:
            # If something else goes wrong, we will *not* fail - otherwise
            # a lot of services seem to fail all at once.
            # Ugly to do it here but...
            finish = timezone.now()
            result.error = 'Error fetching from Jenkins'
            result.succeeded = True
            result.time_complete = finish
            result.save()
            self.last_run = finish
            super(JenkinsStatusCheck, self).save()
            return
        if not active:
            # We will fail if the job has been disabled
            result.error = 'Job "%s" disabled on Jenkins' % self.name
            result.succeeded = False
        else:
            if self.max_queued_build_time and status['blocked_build_time']:
                if status[
                        'blocked_build_time'] > self.max_queued_build_time * 60:
                    result.succeeded = False
                    result.error = 'Job "%s" has blocked build waiting for %ss (> %sm)' % (
                        self.name, int(status['blocked_build_time']),
                        self.max_queued_build_time)
                else:
                    result.succeeded = status['succeeded']
            else:
                result.succeeded = status['succeeded']
            if not status['succeeded']:
                if result.error:
                    result.error += '; Job "%s" failing on Jenkins' % self.name
                else:
                    result.error = 'Job "%s" failing on Jenkins' % self.name
                result.raw_data = status

        finish = timezone.now()
        result.time_complete = finish
        result.save()
        self.last_run = finish
        super(JenkinsStatusCheck, self).save()
コード例 #4
0
ファイル: models.py プロジェクト: yekeqiang/cabot
    def _run(self):
        result = StatusCheckResult(check=self)
        try:
            status = get_job_status(self.name)
            active = status['active']
            if status['status_code'] == 404:
                result.error = u'Job %s not found on Jenkins' % self.name
                result.succeeded = False
                return result
            elif status['status_code'] > 400:
                # Will fall through to next block
                raise Exception(u'returned %s' % status['status_code'])
        except Exception as e:
            # If something else goes wrong, we will *not* fail - otherwise
            # a lot of services seem to fail all at once.
            # Ugly to do it here but...
            result.error = u'Error fetching from Jenkins - %s' % e
            result.succeeded = True
            return result

        if not active:
            # We will fail if the job has been disabled
            result.error = u'Job "%s" disabled on Jenkins' % self.name
            result.succeeded = False
        else:
            if self.max_queued_build_time and status['blocked_build_time']:
                if status[
                        'blocked_build_time'] > self.max_queued_build_time * 60:
                    result.succeeded = False
                    result.error = u'Job "%s" has blocked build waiting for %ss (> %sm)' % (
                        self.name,
                        int(status['blocked_build_time']),
                        self.max_queued_build_time,
                    )
                else:
                    result.succeeded = status['succeeded']
            else:
                result.succeeded = status['succeeded']
            if not status['succeeded']:
                if result.error:
                    result.error += u'; Job "%s" failing on Jenkins' % self.name
                else:
                    result.error = u'Job "%s" failing on Jenkins' % self.name
                result.raw_data = status
        return result
コード例 #5
0
ファイル: models.py プロジェクト: AJamesPhillips/cabot
    def _run(self):
        result = StatusCheckResult(check=self)
        try:
            status = get_job_status(self.name)
            active = status['active']
            if status['status_code'] == 404:
                result.error = u'Job %s not found on Jenkins' % self.name
                result.succeeded = False
                return result
            elif status['status_code'] > 400:
                # Will fall through to next block
                raise Exception(u'returned %s' % status['status_code'])
        except Exception as e:
            # If something else goes wrong, we will *not* fail - otherwise
            # a lot of services seem to fail all at once.
            # Ugly to do it here but...
            result.error = u'Error fetching from Jenkins - %s' % e
            result.succeeded = True
            return result

        if not active:
            # We will fail if the job has been disabled
            result.error = u'Job "%s" disabled on Jenkins' % self.name
            result.succeeded = False
        else:
            if self.max_queued_build_time and status['blocked_build_time']:
                if status['blocked_build_time'] > self.max_queued_build_time * 60:
                    result.succeeded = False
                    result.error = u'Job "%s" has blocked build waiting for %ss (> %sm)' % (
                        self.name,
                        int(status['blocked_build_time']),
                        self.max_queued_build_time,
                    )
                else:
                    result.succeeded = status['succeeded']
            else:
                result.succeeded = status['succeeded']
            if not status['succeeded']:
                if result.error:
                    result.error += u'; Job "%s" failing on Jenkins' % self.name
                else:
                    result.error = u'Job "%s" failing on Jenkins' % self.name
                result.raw_data = status
        return result