@@ -8,9 +8,11 @@ if [ "$#" != 1 ]; then
8
8
exit 1
9
9
fi
10
10
11
+ cmd=$1
12
+
11
13
if [[ " ${DENOISE:- 0} " -eq 0 ]] || [[ " ${BUILD_SYSTEM_DEBUG:- 0} " -eq 1 ]]; then
12
14
set -e
13
- bash -c " $1 "
15
+ bash -c " $cmd "
14
16
exit 0
15
17
fi
16
18
@@ -25,15 +27,39 @@ export FORCE_COLOR=${FORCE_COLOR:-1}
25
27
[ -t 1 ] && realtime=1 || realtime=0
26
28
27
29
key=$( uuid)
30
+ url=http://ci.aztec-labs.com/$key
28
31
outfile=/tmp/$key
29
32
trap ' rm -f $outfile' EXIT
30
33
touch $outfile
31
34
35
+ function publish_log {
36
+ if [ " $CI_REDIS_AVAILABLE " -eq 0 ]; then
37
+ return
38
+ fi
39
+
40
+ {
41
+ echo -e " Command: $cmd (exit: $status )\n"
42
+ cat $outfile
43
+ } | redis_setexz $key $CI_REDIS_EXPIRE
44
+ }
45
+
46
+ function live_publish_log {
47
+ while [ -f $outfile ]; do
48
+ publish_log
49
+ sleep 5
50
+ done
51
+ }
52
+
53
+ if [ " $CI_REDIS_AVAILABLE " -eq 1 ]; then
54
+ live_publish_log &
55
+ log_info=" (${yellow}${url}${reset} )"
56
+ fi
57
+
32
58
# Execute the command and process the output, allow for errors.
33
59
set +e
34
- echo -e " Executing: $1 ( ${yellow} ci llog $key ${reset} ) "
60
+ echo -e " Executing: $cmd ${log_info :- } "
35
61
echo -n " 0 "
36
- bash -c " $1 " 2>&1 | while IFS= read -r line; do
62
+ bash -c " $cmd " 2>&1 | while IFS= read -r line; do
37
63
(( dot_count++ ))
38
64
[ $realtime -eq 1 ] && printf " ."
39
65
if [[ " $dots_per_line " -gt 0 && $(( dot_count % dots_per_line)) -eq 0 ]]; then
@@ -45,26 +71,15 @@ done;
45
71
# Get the exit status of the command
46
72
status=${PIPESTATUS[0]}
47
73
48
- if [ " $CI_REDIS_AVAILABLE " -eq 1 ]; then
49
- {
50
- echo " Command: $1 (exit: $status )"
51
- cat $outfile
52
- } | redis_setexz $key $CI_REDIS_EXPIRE
53
- fi
74
+ publish_log
54
75
55
76
# Handle non-zero exit status
56
77
if [ " $status " -ne 0 ]; then
57
78
echo -e " \nCommand exited with status $status . Dumping output:"
58
79
cat $outfile
59
- echo -e -n " . ${red} failed${reset} (${SECONDS} s)"
80
+ echo -e " . ${red} failed${reset} (${SECONDS} s) ${log_info :- } "
60
81
else
61
- echo -e -n " . ${green} done${reset} (${SECONDS} s)"
62
- fi
63
-
64
- if [ " $CI_REDIS_AVAILABLE " -eq 1 ]; then
65
- url=http://ci.aztec-labs.com/$key
66
- echo -e -n " (${yellow}${url}${reset} )"
82
+ echo -e " . ${green} done${reset} (${SECONDS} s)"
67
83
fi
68
- echo
69
84
70
85
exit $status
0 commit comments