fix(create): quote handling for bash pipefail wrapping of pre/post hooks
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
8750ec1813
commit
359140781e
@ -127,9 +127,12 @@ def run_commands(commands):
|
|||||||
for container, command in commands.items():
|
for container, command in commands.items():
|
||||||
if not command:
|
if not command:
|
||||||
continue
|
continue
|
||||||
|
# Remove bash/sh wrapping
|
||||||
|
command = command.removeprefix('bash -c').removeprefix('sh -c')
|
||||||
|
# Remove quotes surrounding the command
|
||||||
|
if (len(command) >= 2 and command[0] == command[-1] and (command[0] == "'" or command[0] == '"')):
|
||||||
|
command[1:-1]
|
||||||
# Use bash's pipefail to return exit codes inside a pipe to prevent silent failure
|
# Use bash's pipefail to return exit codes inside a pipe to prevent silent failure
|
||||||
command = command.removeprefix('bash -c \'').removeprefix('sh -c \'')
|
|
||||||
command = command.removesuffix('\'')
|
|
||||||
command = f"bash -c 'set -o pipefail;{command}'"
|
command = f"bash -c 'set -o pipefail;{command}'"
|
||||||
logging.info(f"run command in {container.name}:")
|
logging.info(f"run command in {container.name}:")
|
||||||
logging.info(command)
|
logging.info(command)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user