def create_build_job(user, project, config, code_reference, configmap_refs=None, secret_refs=None):
build_job, rebuild = BuildJob.create(<EOL>user=user,<EOL>project=project,<EOL>config=config,<EOL>code_reference=code_reference,<EOL>configmap_refs=configmap_refs,<EOL>secret_refs=secret_refs)<EOL>if build_job.succeeded and not rebuild:<EOL><INDENT>return build_job, True, False<EOL><DEDENT>if build_job.is_done:<EOL><INDENT>build_job, _ = BuildJob.create(<EOL>user=user,<EOL>project=project,<EOL>config=config,<EOL>code_reference=code_reference,<EOL>configmap_refs=configmap_refs,<EOL>secret_refs=secret_refs,<EOL>nocache=True)<EOL><DEDENT>if not build_job.is_running:<EOL><INDENT>auditor.record(event_type=BUILD_JOB_STARTED_TRIGGERED,<EOL>instance=build_job,<EOL>actor_id=user.id,<EOL>actor_name=user.username)<EOL>build_status = start_dockerizer(build_job=build_job)<EOL><DEDENT>else:<EOL><INDENT>build_status = True<EOL><DEDENT>return build_job, False, build_status<EOL>
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])