read dockerfile

This commit is contained in:
Muzahid 2022-02-23 18:52:48 +05:30
parent 483db0d732
commit 98c4b1261f
Signed by: cis-muzahid
GPG Key ID: 1DC85E7D3AB613EA
1 changed files with 14 additions and 2 deletions

View File

@ -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):