コード例 #1
0
ファイル: models.py プロジェクト: kitchhuang/intelic
 def create_jenkins_job(self):
     if not getattr(settings, "JENKINS_HOST"):
         return
     jenkins_handler = JenkinsHandler(settings.JENKINS_HOST, settings.JENKINS_USERNAME, settings.JENKINS_PASSWORD)
     params = self.get_jenkins_params()
     jenkins_handler.trigger(params)
     build_id = jenkins_handler.get_build_id()
     self.extraattr_set.create(name="jenkins_build_id", value=build_id)
コード例 #2
0
ファイル: models.py プロジェクト: kitchhuang/intelic
 def create_jenkins_job(self):
     if not getattr(settings, 'JENKINS_HOST'):
         return
     jenkins_handler = JenkinsHandler(settings.JENKINS_HOST,
                                      settings.JENKINS_USERNAME,
                                      settings.JENKINS_PASSWORD)
     params = self.get_jenkins_params()
     jenkins_handler.trigger(params)
     build_id = jenkins_handler.get_build_id()
     self.extraattr_set.create(name='jenkins_build_id', value=build_id)
コード例 #3
0
ファイル: models.py プロジェクト: kitchhuang/intelic
def update_process_handler(sender, instance, **kwargs):
    # Fake data here
    now = timezone.now()
    processes = instance.process_set.all()

    if getattr(settings, "JENKINS_HOST"):
        jenkins_handler = JenkinsHandler(settings.JENKINS_HOST, settings.JENKINS_USERNAME, settings.JENKINS_PASSWORD)
    else:
        jenkins_handler = None

    for process in processes:
        if not process.started_at:
            continue
        progress, remaining_seconds = process.get_progress(commit=True)
        # Skip package process
        if process.type == "Package":
            continue
        # Do build job
        if not jenkins_handler:
            if progress == 100:
                # Fake data
                if instance.has_components:
                    process.url = "/media/all_patched/baylake-eng-fastboot-eng.chenxf.zip"
                else:
                    process.url = "/media/default/baylake-eng-fastboot-eng.chenxf.zip"
            process.save()
            return
        # Do jenkins work
        jenkins_build_ids = instance.process_set.get(type="Build").extraattr_set.filter(name="jenkins_build_id")
        if jenkins_build_ids:
            jenkins_build_id = jenkins_build_ids[0].value
        else:
            return
        jenkins_handler.get_build(id=int(jenkins_build_id))
        is_completed, status = jenkins_handler.is_complete()
        if is_completed == 200:  # Succeed
            process.progress = 100
            process.url = jenkins_handler.get_build_results()
            process.status = "Completed"
            process.save()
        elif is_completed == 500:  # Failure
            process.progress = 100
            process.status = status
            process.message = "Build failed, please check your settings or code."
            process.url = None
            process.save()
コード例 #4
0
ファイル: models.py プロジェクト: kitchhuang/intelic
def update_process_handler(sender, instance, **kwargs):
    # Fake data here
    now = timezone.now()
    processes = instance.process_set.all()

    if getattr(settings, 'JENKINS_HOST'):
        jenkins_handler = JenkinsHandler(settings.JENKINS_HOST,
                                         settings.JENKINS_USERNAME,
                                         settings.JENKINS_PASSWORD)
    else:
        jenkins_handler = None

    for process in processes:
        if not process.started_at:
            continue
        progress, remaining_seconds = process.get_progress(commit=True)
        # Skip package process
        if process.type == 'Package':
            continue
        # Do build job
        if not jenkins_handler:
            if progress == 100:
                # Fake data
                if instance.has_components:
                    process.url = '/media/all_patched/baylake-eng-fastboot-eng.chenxf.zip'
                else:
                    process.url = '/media/default/baylake-eng-fastboot-eng.chenxf.zip'
            process.save()
            return
        # Do jenkins work
        jenkins_build_ids = instance.process_set.get(
            type='Build').extraattr_set.filter(name='jenkins_build_id')
        if jenkins_build_ids:
            jenkins_build_id = jenkins_build_ids[0].value
        else:
            return
        jenkins_handler.get_build(id=int(jenkins_build_id))
        is_completed, status = jenkins_handler.is_complete()
        if is_completed == 200:  # Succeed
            process.progress = 100
            process.url = jenkins_handler.get_build_results()
            process.status = 'Completed'
            process.save()
        elif is_completed == 500:  # Failure
            process.progress = 100
            process.status = status
            process.message = 'Build failed, please check your settings or code.'
            process.url = None
            process.save()