Пример #1
0
    def update_score_view(self):
        if self.connected is False:
            return False

        if self.jenkins is None:
            return False

        for job_status in self.jenkins.get_view_status(self.score_view):

            last_build_number = job_status["last_build"]
            last_build_status = job_status["status"]
            job_name = job_status["project"]
            logging.debug("Update view score for job: " + job_name)

            if need_to_add_job(job_name):
                scoreJob = ScoreJob(name=job_name,
                                    last_build_number=last_build_number,
                                    last_build_status=last_build_status)
                scoreJob.save()
                logging.log(logging.DEBUG, "Inserted job: " + job_name)

            if job_status is not None:
                self.update_score_job(job_status)

        return True
Пример #2
0
    def test_need_to_add_job(self):
        job = ScoreJob()
        job.name = "Job1"
        job.save()

        self.assertFalse(need_to_add_job("Job1"))
        self.assertTrue(need_to_add_job("Job2"))
Пример #3
0
    def update_user_score(self, job_status):

        if self.connected is False:
            return False

        score_job = ScoreJob.objects(name=job_status["project"]).first()

        score_last_build_number = score_job.last_build_number
        if score_last_build_number == job_status["last_build"]:
            return True

        job = self.jenkins.get_job(job_status["project"])
        for build_number in range(score_last_build_number + 1,
                                  job_status["last_build"] + 1):
            logging.log(
                logging.DEBUG, "Updating user score for job: " +
                job_status["project"] + " Build: " + str(build_number))
            build = job.get_build(build_number)
            if self.update_score_build(job, build):
                score_job.update(set__last_build_number=build_number)

        return True
Пример #4
0
    def update_score_job(self, job_status):

        if self.connected is False:
            return False

        score_job = ScoreJob.objects(name=job_status["project"]).first()

        score_last_build_number = score_job.last_build_number
        if score_last_build_number == job_status["last_build"]:
            return True

        job = self.jenkins.get_job(job_status["project"])
        for build_number in range(score_last_build_number + 1,
                                  job_status["last_build"] + 1):
            build = self.jenkins.get_build(build_number, job)
            if build is None:
                continue

            if self.update_score_build(job, build):
                score_job.update(set__last_build_number=build_number)

        return True
Пример #5
0
 def clear_db(self):
     if self.is_connected():
         User.drop_collection()
         ScoreJob.drop_collection()
         Config.drop_collection()