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

Commit 3ee5fc4

Browse files
author
Mira Ressel
committed
[DRAFT] timestamp gitlab ci job outputs
Based on previous work by @alvicsam in #13047. TODO: Update jobs that override after_script
1 parent 39510ec commit 3ee5fc4

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

.gitlab-ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,21 @@ variables:
110110
before_script:
111111
- if echo "$CI_DISABLED_JOBS" | grep -xF "$CI_JOB_NAME"; then echo "The job has been cancelled in CI settings"; exit 0; fi
112112

113+
.timestamp:
114+
before_script:
115+
- source scripts/ci/gitlab/timestamp.sh
116+
after_script:
117+
- exec >/dev/null 2>&1
118+
- wait ${TIMESTAMP_PID}
119+
113120
.kubernetes-env:
114121
image: "${CI_IMAGE}"
115122
before_script:
123+
- !reference [.timestamp, before_script]
116124
- !reference [.job-switcher, before_script]
117125
- !reference [.prepare-env, before_script]
126+
after_script:
127+
- !reference [.timestamp, after_script]
118128
tags:
119129
- kubernetes-parity-build
120130

@@ -141,13 +151,15 @@ variables:
141151
.docker-env:
142152
image: "${CI_IMAGE}"
143153
before_script:
154+
- !reference [.timestamp, before_script]
144155
- !reference [.job-switcher, before_script]
145156
- !reference [.prepare-env, before_script]
146157
- !reference [.rust-info-script, script]
147158
- !reference [.rusty-cachier, before_script]
148159
- !reference [.pipeline-stopper-vars, script]
149160
after_script:
150161
- !reference [.rusty-cachier, after_script]
162+
- !reference [.timestamp, after_script]
151163
tags:
152164
- linux-docker
153165

scripts/ci/gitlab/timestamp.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# https://gist.github.com/altaua/477285db40181ef1793bbed5bae32c6b
2+
# based on https://gist.github.com/jstine35/e0fc0e06ec06d74bc3ebd67585bf2a1d
3+
# edited to use just a single process substitution
4+
# and print the last line of output even if it isn't \n-terminated
5+
6+
s_datestamp() {
7+
8+
eof=""
9+
while [[ -z "${eof}" ]]; do
10+
11+
IFS="" read -r line || eof=1
12+
timestamp=$(date -u '+%Y-%m-%d %H:%M:%S')
13+
14+
printf '[%s] %s\n' "${timestamp}" "${line}"
15+
16+
done
17+
}
18+
19+
exec > >(s_datestamp) 2>&1
20+
TIMESTAMP_PID=$!
21+
22+
# at the end of the script, wait for the process substitution before exiting:
23+
# exec >/dev/null 2>&1
24+
# wait ${TIMESTAMP_PID}

0 commit comments

Comments
 (0)