From 98c4b1261f50fd28c1e6e1f38739df1588b8aa36 Mon Sep 17 00:00:00 2001 From: Muzahid Date: Wed, 23 Feb 2022 18:52:48 +0530 Subject: [PATCH] read dockerfile --- lib/worker_multibuild.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/worker_multibuild.py b/lib/worker_multibuild.py index 5df2be7..71877f3 100644 --- a/lib/worker_multibuild.py +++ b/lib/worker_multibuild.py @@ -73,12 +73,24 @@ def _get_dockerfile_contents(jobname, os_codename='bionic'): """ Read contents of a Dockerfile and add extra contents for the given os_codename """ + res = "" with open(join(path + jobname), "r") as file: contents = file.read() # accept any line containing FROM or RUN keywords - re.match(r"(?m)^(FROM|RUN).*$", contents) + # re.match(r"(?m)^(FROM|RUN).*$", contents) - return contents + dockerfile_extra_contents[os_codename] + for i in range(len(contents)): + if re.match(r"(?m)^(FROM|RUN).*$", contents[i]): + res += contents[i] + j = i + while True: + if "\\" in contents[j]: + res += contents[j+1] + j = j + 1 + else: + break + + return res + dockerfile_extra_contents[os_codename] def trigger_child_hooks(buildbotUrl: str, os_codename: str, repository, branch, jobname, directory=".buildbot", is_build_script_available, is_test_script_available):