2014-05-30 15:15:51 -07:00
|
|
|
#!/bin/bash -xe
|
|
|
|
|
2015-01-27 15:26:31 +11:00
|
|
|
RETRY_LIMIT=20
|
|
|
|
|
2015-01-30 10:49:13 +11:00
|
|
|
# Keep fetching until this uuid appears in the logs before uploading
|
2015-01-27 11:15:59 +11:00
|
|
|
END_UUID=$(cat /proc/sys/kernel/random/uuid)
|
|
|
|
|
|
|
|
echo "Grabbing consoleLog ($END_UUID)"
|
2014-05-30 15:15:51 -07:00
|
|
|
|
2015-10-07 09:58:33 -05:00
|
|
|
# Since we are appending to fetched logs, clear any possibly old runs
|
2015-11-11 14:36:27 -08:00
|
|
|
# Don't add a newline so we end up with a 0 byte file.
|
|
|
|
echo -n > /tmp/console.html
|
2014-10-07 16:58:57 +11:00
|
|
|
|
|
|
|
# Grab the HTML version of the log (includes timestamps)
|
2015-01-27 15:26:31 +11:00
|
|
|
TRIES=0
|
2014-10-07 16:58:57 +11:00
|
|
|
console_log_path='logText/progressiveHtml'
|
2015-01-27 11:15:59 +11:00
|
|
|
while ! grep -q "$END_UUID" /tmp/console.html; do
|
2015-01-27 15:26:31 +11:00
|
|
|
TRIES=$((TRIES+1))
|
|
|
|
if [ $TRIES -gt $RETRY_LIMIT ]; then
|
2015-10-07 09:58:33 -05:00
|
|
|
echo "Failed grabbing consoleLog within $RETRY_LIMIT retries."
|
2015-01-27 15:26:31 +11:00
|
|
|
break
|
2015-01-27 16:47:17 +11:00
|
|
|
fi
|
2015-01-27 11:15:59 +11:00
|
|
|
sleep 3
|
2015-03-18 10:22:14 -07:00
|
|
|
# -X POST because Jenkins doesn't do partial gets properly when
|
|
|
|
# job is running.
|
|
|
|
# --data start=X instructs Jenkins to mimic a partial get using
|
|
|
|
# POST. We determine how much data we need based on
|
|
|
|
# how much we already have.
|
|
|
|
# --fail will cause curl to not output data if the request
|
|
|
|
# fails. This allows us to retry when we have Jenkins proxy
|
|
|
|
# errors without polluting the output document.
|
|
|
|
# --insecure because our Jenkins masters use self signed SSL certs.
|
2015-12-23 13:36:33 +01:00
|
|
|
curl -X POST --data "start=$(stat -c %s /tmp/console.html || echo 0)" \
|
|
|
|
--fail --insecure $BUILD_URL$console_log_path \
|
|
|
|
>> /tmp/console.html || true
|
2015-01-27 11:15:59 +11:00
|
|
|
done
|
2014-10-07 16:58:57 +11:00
|
|
|
|
|
|
|
# We need to add <pre> tags around the output for log-osanalyze to not escape
|
|
|
|
# the content
|
|
|
|
|
|
|
|
sed -i '1s/^/<pre>\n/' /tmp/console.html
|
|
|
|
echo "</pre>" >> /tmp/console.html
|