catch exception when build image error
@@ -887,6 +887,14 @@ class RunJob(Job):
if self.job['definition'].get('cache', {}).get('image', False) or self.job['definition'].get('deployments', None):
c.execute(("docker", "commit", container_name, image_name))
except Exception as e:
+ try:
+ # Find out if container build was failed
+ out = subprocess.check_output(['docker', 'images', '-q', image_name]).strip()
+ if not out:
+ raise Failure("Could not build image of container")
+ except Exception as ex:
+ logger.exception(ex)
+ raise Failure("Error while executing subprocess 'docker images -q %s'" % image_name)
try:
# Find out if container was killed due to oom
out = subprocess.check_output(['docker', 'inspect', container_name,
