def run(self, repo: str, branch: str, task: Task, git_repo: Repo, repo_path: Path) -> Result:
self.check_docker_access()<EOL>container_name = self.get_container_name(repo, branch, git_repo)<EOL>container = self.container_running(container_name)<EOL>if container is None:<EOL><INDENT>image = self.get_image_for_repo(repo, branch, git_repo, repo_path)<EOL>container = self.start_container(image, container_name, repo_path)<EOL><DEDENT>task_filename, task_json = self.serialized_task(task)<EOL>container.put_archive("<STR_LIT>", self.tar_task_definition(task_filename, task_json))<EOL>res = None<EOL>try:<EOL><INDENT>command = ["<STR_LIT>"]<EOL>if self.inherit_image:<EOL><INDENT>if self.alpine_inherited or b"<STR_LIT>" in container.exec_run(["<STR_LIT>", "<STR_LIT>"], tty=True).output:<EOL><INDENT>self.alpine_inherited = True<EOL>command = ["<STR_LIT>", "<STR_LIT>"]<EOL><DEDENT><DEDENT>command += [str(task.timeout),<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>f"<STR_LIT>"]<EOL>logger.debug("<STR_LIT>", "<STR_LIT:U+0020>".join(command))<EOL>res = container.exec_run(command, tty=True)<EOL>if res.exit_code in {<NUM_LIT>, <NUM_LIT>}:<EOL><INDENT>raise BuildTimeoutError(f"<STR_LIT>")<EOL><DEDENT>return Result(res.output)<EOL><DEDENT>except BuildError:  <EOL><INDENT>raise<EOL><DEDENT>except Exception as e:<EOL><INDENT>logger.exception(e)<EOL>if res is not None:<EOL><INDENT>logger.warning(res.output)<EOL><DEDENT>raise BuildError("<STR_LIT>", extra_info={<EOL>"<STR_LIT>": e,<EOL>"<STR_LIT>": res if res is None else res.output<EOL>})<EOL><DEDENT>finally:<EOL><INDENT>if not self.keep_container_running:<EOL><INDENT>container.kill(signal.SIGKILL)<EOL><DEDENT>else:<EOL><INDENT>self._containers.add(container)<EOL><DEDENT><DEDENT>
Gets or builds an image for the repo, gets or starts a container for the image and runs the script.

        :param repo: Repository URL
        :param branch: Branch ane
        :param task: :class:`Task` to run.
        :param git_repo: :class:`Repo <git.repo.base.Repo>` of the cloned repository.
        :param repo_path: :class:`Path <pathlib.Path>` to the cloned location.