Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
timestamp gitlab ci job outputs
Browse files Browse the repository at this point in the history
Based on previous work by @alvicsam in #13047.
  • Loading branch information
Mira Ressel committed Mar 15, 2023
1 parent ae83a67 commit e6be50a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down
21 changes: 21 additions & 0 deletions scripts/ci/gitlab/timestamp.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e6be50a

Please sign in to comment.