for_all_repos: Exit on command failure

KAS should exit with the appropriate exit code, if the command parsed to the for_all_repos
plugin fails to apply on one of the repositories.

Example use-case: This allows for CI pipelines or wrapper scripts to take appropriate action (e.g. fail),
if an issue occured within the KAS for_all_repos command.

Signed-off-by: Jasper Orschulko <jasper@fancydomain.eu>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jasper Orschulko 2021-08-24 20:55:24 +02:00 committed by Jan Kiszka
parent fca78e5601
commit 9732ec16f2

View File

@ -55,6 +55,7 @@
import logging import logging
import subprocess import subprocess
import sys
from kas.context import create_global_context from kas.context import create_global_context
from kas.config import Config from kas.config import Config
from kas.libcmds import Macro, Command from kas.libcmds import Macro, Command
@ -105,6 +106,7 @@ class ForAllReposCommand(Command):
env=env) env=env)
if retcode != 0: if retcode != 0:
logging.error('Command failed with return code %d', retcode) logging.error('Command failed with return code %d', retcode)
sys.exit(retcode)
__KAS_PLUGINS__ = [ForAllRepos] __KAS_PLUGINS__ = [ForAllRepos]