From e6be50a5d5e8d306c8424d6322ddda2b3e375d05 Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Tue, 14 Mar 2023 20:30:32 +0100 Subject: [PATCH] timestamp gitlab ci job outputs Based on previous work by @alvicsam in #13047. --- .gitlab-ci.yml | 6 ++++++ scripts/ci/gitlab/timestamp.sh | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 scripts/ci/gitlab/timestamp.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94fb3c608b771..5a9003739dfd1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,9 +110,14 @@ variables: before_script: - if echo "$CI_DISABLED_JOBS" | grep -xF "$CI_JOB_NAME"; then echo "The job has been cancelled in CI settings"; exit 0; fi +.timestamp: + before_script: + - source scripts/ci/gitlab/timestamp.sh + .kubernetes-env: image: "${CI_IMAGE}" before_script: + - !reference [.timestamp, before_script] - !reference [.job-switcher, before_script] - !reference [.prepare-env, before_script] tags: @@ -141,6 +146,7 @@ variables: .docker-env: image: "${CI_IMAGE}" before_script: + - !reference [.timestamp, before_script] - !reference [.job-switcher, before_script] - !reference [.prepare-env, before_script] - !reference [.rust-info-script, script] diff --git a/scripts/ci/gitlab/timestamp.sh b/scripts/ci/gitlab/timestamp.sh new file mode 100755 index 0000000000000..cd6caf947dad1 --- /dev/null +++ b/scripts/ci/gitlab/timestamp.sh @@ -0,0 +1,21 @@ +# https://gist.github.com/altaua/477285db40181ef1793bbed5bae32c6b +# based on https://gist.github.com/jstine35/e0fc0e06ec06d74bc3ebd67585bf2a1d + +s_datestamp() { + TZ=UTC + eof="" + while [[ -z "${eof}" ]]; do + IFS="" read -r line || eof=1 + printf '[%(%F %T)T] %s\n' -1 "${line}" + done +} + +cleanup() { + exec >/dev/null 2>&1 + wait "${TIMESTAMP_PID}" +} + +exec > >(s_datestamp) 2>&1 + +TIMESTAMP_PID=$! +trap cleanup EXIT