Commit ac1ada1c authored by Raphael Defosseux's avatar Raphael Defosseux

fix(ci): when the shared image dockerfile is being modified, force its build

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 9682881c
...@@ -195,6 +195,7 @@ class Containerize(): ...@@ -195,6 +195,7 @@ class Containerize():
# the potential merge. Note that merge conflicts should already been checked earlier # the potential merge. Note that merge conflicts should already been checked earlier
imageTag = 'develop' imageTag = 'develop'
sharedTag = 'develop' sharedTag = 'develop'
forceSharedImageBuild = False
if (self.ranAllowMerge): if (self.ranAllowMerge):
imageTag = 'ci-temp' imageTag = 'ci-temp'
if self.ranTargetBranch == '': if self.ranTargetBranch == '':
...@@ -203,6 +204,13 @@ class Containerize(): ...@@ -203,6 +204,13 @@ class Containerize():
else: else:
logging.debug('Merging with the target branch: ' + self.ranTargetBranch) logging.debug('Merging with the target branch: ' + self.ranTargetBranch)
mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5)
mySSH.command('git diff HEAD..origin/develop -- docker/Dockerfile.ran' + self.dockerfileprefix + ' | grep -i INDEX', '\$', 5)
result = re.search('index', mySSH.getBefore())
if result is not None:
forceSharedImageBuild = True
sharedTag = 'ci-temp'
else:
forceSharedImageBuild = True
# if asterix, copy the entitlement and subscription manager configurations # if asterix, copy the entitlement and subscription manager configurations
if self.host == 'Red Hat': if self.host == 'Red Hat':
...@@ -214,13 +222,14 @@ class Containerize(): ...@@ -214,13 +222,14 @@ class Containerize():
sharedimage = 'ran-build' sharedimage = 'ran-build'
# Let's remove any previous run artifacts if still there # Let's remove any previous run artifacts if still there
mySSH.command(self.cli + ' image prune --force', '\$', 30) mySSH.command(self.cli + ' image prune --force', '\$', 30)
if (not self.ranAllowMerge): if forceSharedImageBuild:
mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag, '\$', 30) mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag + ' || true', '\$', 30)
for image,pattern in imageNames: for image,pattern in imageNames:
mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag, '\$', 30) mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag + ' || true', '\$', 30)
# Build the shared image only on Push Events (not on Merge Requests) # Build the shared image only on Push Events (not on Merge Requests)
if (not self.ranAllowMerge): # On when the shared image docker file is being modified.
if forceSharedImageBuild:
mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600) mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600)
# First verify if the shared image was properly created. # First verify if the shared image was properly created.
status = True status = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment