From a6e1926a8e0a0d17338616afc1b543895f2f4924 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Mon, 19 May 2025 09:11:22 +0200 Subject: [PATCH] ci: Fix date parsing with BusyBox on Alpine This fixes the timestamps in Alpine containers. Signed-off-by: Valentine Burley Part-of: --- .gitlab-ci/setup-test-env.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/setup-test-env.sh b/.gitlab-ci/setup-test-env.sh index 32a4eb8f2b4..110dd8e55ee 100644 --- a/.gitlab-ci/setup-test-env.sh +++ b/.gitlab-ci/setup-test-env.sh @@ -33,7 +33,13 @@ function _error_msg() ( echo -e "${RED}$*${ENDCOLOR}" ) -export JOB_START_S=$(date -u +"%s" -d "${CI_JOB_STARTED_AT:?}") +# Some date binaries (like the BusyBox one) use -D instead of -d for date parsing. +# This fallback handles both cases: try GNU coreutils-style first, then fallback to BusyBox if it fails. +# The BusyBox fallback needs '|| true' because it returns an error status even when it outputs the time. +export JOB_START_S=$( + date -u +"%s" -d "$CI_JOB_STARTED_AT" 2>/dev/null || + { date -u +"%s" -D "%Y-%m-%dT%H:%M:%SZ" "$CI_JOB_STARTED_AT" 2>/dev/null || true; } +) function get_current_minsec { DATE_S=$(date -u +"%s")