def create_build_job(user, project, config, code_reference, configmap_refs=None, secret_refs=None):
    """Get or Create a build job based on the params.

    If a build job already exists, then we check if the build has already an image created.
    If the image does not exists, and the job is already done we force create a new job.

    Returns:
        tuple: (build_job, image_exists[bool], build_status[bool])
    """
    build_job, rebuild = BuildJob.create(
        user=user,
        project=project,
        config=config,
        code_reference=code_reference,
        configmap_refs=configmap_refs,
        secret_refs=secret_refs)

    if build_job.succeeded and not rebuild:
        return build_job, True, False

    if build_job.is_done:
        build_job, _ = BuildJob.create(
            user=user,
            project=project,
            config=config,
            code_reference=code_reference,
            configmap_refs=configmap_refs,
            secret_refs=secret_refs,
            nocache=True)

    if not build_job.is_running:
        # We need to build the image first
        auditor.record(event_type=BUILD_JOB_STARTED_TRIGGERED,
                       instance=build_job,
                       actor_id=user.id,
                       actor_name=user.username)
        build_status = start_dockerizer(build_job=build_job)
    else:
        build_status = True

    return build_job, False, build_status
def create_build_job ( user , project , config , code_reference , configmap_refs = None , secret_refs = None ) : build_job , rebuild = BuildJob . create ( user = user , project = project , config = config , code_reference = code_reference , configmap_refs = configmap_refs , secret_refs = secret_refs ) if build_job . succeeded and not rebuild : return build_job , True , False if build_job . is_done : build_job , _ = BuildJob . create ( user = user , project = project , config = config , code_reference = code_reference , configmap_refs = configmap_refs , secret_refs = secret_refs , nocache = True ) if not build_job . is_running : auditor . record ( event_type = BUILD_JOB_STARTED_TRIGGERED , instance = build_job , actor_id = user . id , actor_name = user . username ) build_status = start_dockerizer ( build_job = build_job ) else : build_status = True return build_job , False , build_status
Get or Create a build job based on the params.

    If a build job already exists, then we check if the build has already an image created.
    If the image does not exists, and the job is already done we force create a new job.

    Returns:
        tuple: (build_job, image_exists[bool], build_status[bool])