diff --git a/build_image.py b/build_image.py index 8a6051edb..06ab70ae9 100755 --- a/build_image.py +++ b/build_image.py @@ -48,7 +48,9 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG_SUFFIX}", args.tag_suffix) @@ -57,7 +59,9 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_pcg_listener.py b/build_image_pcg_listener.py index f0d6c2ab3..a1d6e1956 100755 --- a/build_image_pcg_listener.py +++ b/build_image_pcg_listener.py @@ -22,7 +22,9 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG}", args.tag) @@ -30,10 +32,14 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag pcg_listener_{args.tag}.") - subprocess.call(f"git tag pcg_listener_{args.tag} && git push origin pcg_listener_{args.tag}", shell=True) + if subprocess.call(f"git tag pcg_listener_{args.tag} && git push origin pcg_listener_{args.tag}", shell=True) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_segment_update_worker.py b/build_image_segment_update_worker.py index 089239ffb..56f1b8e17 100755 --- a/build_image_segment_update_worker.py +++ b/build_image_segment_update_worker.py @@ -35,7 +35,9 @@ def main(): .replace("{REPO}", args.repo) ) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = ( PUSH_COMMAND_TMPL.replace("{TAG}", args.tag) @@ -44,13 +46,17 @@ def main(): .replace("{REPO}", args.repo) ) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag segment_update_worker_{args.tag}.") - subprocess.call( + if subprocess.call( f"git tag segment_update_worker_{args.tag} && git push origin segment_update_worker_{args.tag}", shell=True, - ) + ) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_web.py b/build_image_web.py index 491bc9416..f1f06e2a1 100755 --- a/build_image_web.py +++ b/build_image_web.py @@ -22,7 +22,10 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + # Stop if build fails + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG}", args.tag) @@ -30,10 +33,14 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag {args.tag}.") - subprocess.call(f"git tag {args.tag} && git push origin {args.tag}", shell=True) + if subprocess.call(f"git tag {args.tag} && git push origin {args.tag}", shell=True) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__": diff --git a/build_image_web_gpu.py b/build_image_web_gpu.py index d2ae4bea6..edd1db4d3 100755 --- a/build_image_web_gpu.py +++ b/build_image_web_gpu.py @@ -22,7 +22,9 @@ def main(): build_command = build_command.replace("{REGION}", args.region) build_command = build_command.replace("{REPO}", args.repo) print(f"Running: \n{build_command}") - subprocess.call(build_command, shell=True) + if subprocess.call(build_command, shell=True) != 0: + print("Build failed, exiting.") + return push_command = PUSH_COMMAND_TMPL push_command = push_command.replace("{TAG}", args.tag) @@ -30,10 +32,14 @@ def main(): push_command = push_command.replace("{REGION}", args.region) push_command = push_command.replace("{REPO}", args.repo) print(f"Running: \n{push_command}") - subprocess.call(push_command, shell=True) + if subprocess.call(push_command, shell=True) != 0: + print("Push failed, exiting.") + return print(f"\nAdding git tag {args.tag}_gpu.") - subprocess.call(f"git tag {args.tag}_gpu && git push origin {args.tag}_gpu", shell=True) + if subprocess.call(f"git tag {args.tag}_gpu && git push origin {args.tag}_gpu", shell=True) != 0: + print("Git tagging failed, exiting.") + return if __name__ == "__main__":