Skip to content

Commit 8fa9ee4

Browse files
author
Trong Nhan Mai
committed
fix: make sure to return the status of the docker run command from run_macaron.sh
Signed-off-by: Trong Nhan Mai <[email protected]>
1 parent e98de40 commit 8fa9ee4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/release_scripts/run_macaron.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,18 @@ function mount_file() {
259259
mounts+=("-v" "${file_on_host}:${file_in_container}:${mount_option}")
260260
}
261261

262+
# Clean up the token file and EXIT this bash script with the given status code.
263+
#
264+
# Arguments:
265+
# $1: The eventual exit status code.
266+
# $2: The path to the token file.
267+
function clean_up_exit() {
268+
status_code=$1
269+
token_file_path=$2
270+
rm -f "$token_file_path"
271+
exit "$status_code"
272+
}
273+
262274
# Parse main arguments.
263275
while [[ $# -gt 0 ]]; do
264276
case $1 in
@@ -599,7 +611,7 @@ mount_file "macaron_env_file" ${TOKEN_FILE} ${MACARON_WORKSPACE}/${TOKEN_FILE} "
599611
set -u
600612

601613
# Force docker to use linux/amd64 platform in order to make docker use emulation on ARM host platforms.
602-
# We need the `docker run` command to be within `set +e`` so that when it returns a non-zero status code,
614+
# We need the `docker run` command to be within `set +e` so that when it returns a non-zero status code,
603615
# it doesn't exit right away and still run the token file cleaning up command.
604616
set +e
605617
docker run \
@@ -614,6 +626,5 @@ docker run \
614626
"${IMAGE}:${MACARON_IMAGE_TAG}" \
615627
"${entrypoint[@]}" \
616628
"${macaron_args[@]}"
617-
set -e
618629

619-
rm -f "$TOKEN_FILE"
630+
clean_up_exit "$?" "$TOKEN_FILE"

0 commit comments

Comments
 (0)