fix the issue with the unsafe git repository

This commit is contained in:
Quentin Guilloteau 2024-09-12 14:07:19 +02:00
parent db4e4f3baf
commit 95fa82edaa

View File

@ -76,8 +76,11 @@ def buildresult_saver(result, buildstatus_path, config_path):
def build_image(path, dockerfile_path, image_name, build_args): def build_image(path, dockerfile_path, image_name, build_args):
logging.info(f"Starting building image {image_name}") logging.info(f"Starting building image {image_name}")
build_command = f"docker build --no-cache -t {image_name} -f {dockerfile_path}"
if len(build_args) != 0:
build_args_str = " ".join(map(lambda x: f"--build-arg {x}", build_args)) build_args_str = " ".join(map(lambda x: f"--build-arg {x}", build_args))
build_command = f"docker build --no-cache -t {image_name} {build_args_str} -f {dockerfile_path} ." build_command += build_args_str
build_command += " ."
build_process = subprocess.run(build_command.split(" "), cwd=path, capture_output=True) build_process = subprocess.run(build_command.split(" "), cwd=path, capture_output=True)
build_output = f"stdout:\n{build_process.stdout.decode('utf-8')}\nstderr:\n{build_process.stderr.decode('utf-8')}" build_output = f"stdout:\n{build_process.stdout.decode('utf-8')}\nstderr:\n{build_process.stderr.decode('utf-8')}"
logging.info(f"Output of '{build_command}':\n\n{build_output}") logging.info(f"Output of '{build_command}':\n\n{build_output}")
@ -144,7 +147,7 @@ def check_env(config, src_dir, artifact_name, pkglist_path):
} }
# Command to obtain the latest commit hash in a git repository (separated # Command to obtain the latest commit hash in a git repository (separated
# into 2 parts for "--entrypoint"): # into 2 parts for "--entrypoint"):
gitcmd = ("git", "log -n 1 --pretty=format:%H") gitcmd = ("git", "-c safe.directory=* log -n 1 --pretty=format:%H")
logging.info("Checking software environment") logging.info("Checking software environment")
pkglist_file = open(pkglist_path, "w") pkglist_file = open(pkglist_path, "w")