![Clark Boylan](/assets/img/avatar_default.png)
Rather than use GET and a range Jenkins uses POSTs with start=beginningindex to do partial downloads of the console text and console html files. Why? Who knows. Support this ridiculousness in our grab console log script so that we can get entire logs. Change-Id: Ie653f3d8980dbf8e8606e6584a9c0ab40d2485ca
42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/bin/bash -xe
|
|
|
|
RETRY_LIMIT=20
|
|
|
|
# Keep fetching until this uuid appears in the logs before uploading
|
|
END_UUID=$(cat /proc/sys/kernel/random/uuid)
|
|
|
|
echo "Grabbing consoleLog ($END_UUID)"
|
|
|
|
# Since we are appending to fetched logs, remove any possibly old runs
|
|
rm -f /tmp/console.txt /tmp/console.html
|
|
|
|
# Get the plain text version (does not contain links or timestamps)
|
|
TRIES=0
|
|
console_log_path='consoleText'
|
|
while ! grep -q "$END_UUID" /tmp/console.txt; do
|
|
TRIES=$((TRIES+1))
|
|
if [ $TRIES -gt $RETRY_LIMIT ]; then
|
|
break
|
|
fi
|
|
sleep 3
|
|
curl -X POST --data "start=$(stat -c %s /tmp/console.txt || echo 0)" --insecure $BUILD_URL$console_log_path >> /tmp/console.txt
|
|
done
|
|
|
|
# Grab the HTML version of the log (includes timestamps)
|
|
TRIES=0
|
|
console_log_path='logText/progressiveHtml'
|
|
while ! grep -q "$END_UUID" /tmp/console.html; do
|
|
TRIES=$((TRIES+1))
|
|
if [ $TRIES -gt $RETRY_LIMIT ]; then
|
|
break
|
|
fi
|
|
sleep 3
|
|
curl -X POST --data "start=$(stat -c %s /tmp/console.html || echo 0)" --insecure $BUILD_URL$console_log_path >> /tmp/console.html
|
|
done
|
|
|
|
# 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
|