diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 90298297a89c6..dee088ff84de8 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: + - if [ -z ${TIMESTAMP_DISABLED} ]; then source scripts/ci/gitlab/timestamp.sh; fi + .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/pipeline/publish.yml b/scripts/ci/gitlab/pipeline/publish.yml index d1a7514d1707b..33eff5c2f95f6 100644 --- a/scripts/ci/gitlab/pipeline/publish.yml +++ b/scripts/ci/gitlab/pipeline/publish.yml @@ -11,6 +11,7 @@ GIT_STRATEGY: none DOCKERFILE: $PRODUCT.Dockerfile IMAGE_NAME: docker.io/$IMAGE_PATH + TIMESTAMP_DISABLED: "true" before_script: - !reference [.kubernetes-env, before_script] - cd ./artifacts/$PRODUCT/ diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index a468a7b04caeb..d58cbe0b8a5de 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -308,6 +308,7 @@ test-linux-stable-int: WASM_BUILD_RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" # Ensure we run the UI tests. RUN_UI_TESTS: 1 + # TIMESTAMP_DISABLED: "true" script: - rusty-cachier snapshot create - WASM_BUILD_NO_COLOR=1 diff --git a/scripts/ci/gitlab/timestamp.sh b/scripts/ci/gitlab/timestamp.sh new file mode 100755 index 0000000000000..6f2edc21b374f --- /dev/null +++ b/scripts/ci/gitlab/timestamp.sh @@ -0,0 +1,20 @@ +# Original script from: https://gist.github.com/jstine35/e0fc0e06ec06d74bc3ebd67585bf2a1d +# By @jstine35 on GitHub + + +s_datestamp() { + while read -r line; do + timestamp=$(date -u '+%Y-%m-%d %H:%M:%S') + + # by nature BASH might run process subst twice when using >&2 pipes. This is a lazy + # way to avoid dumping two timestamps on the same line: + if [[ "$line" != \[${timestamp%% *}* ]]; then + echo "[$timestamp] $line" + else + echo "$line" + fi + done +} + +exec 1> >(s_datestamp) +exec 2> >(s_datestamp)