Log output of site building into file, to avoid travis log file limit

See also http://stackoverflow.com/questions/26082444/how-to-work-around-travis-cis-4mb-output-limit/26082445#26082445
This commit is contained in:
Andreas Dangel
2017-02-25 11:31:09 +01:00
parent dea5babb94
commit 4d16c8d2d2
3 changed files with 53 additions and 6 deletions

View File

@ -10,14 +10,13 @@ else
mvn deploy -Possrh,pmd-release -B -V
fi
mvn site site:stage -Psite -B -V
bash .travis/build-site.sh
# create pmd-doc archive
(
cd target
mv staging pmd-doc-${VERSION}
zip -r pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/
zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/
)
# Uploading pmd distribution to sourceforge
@ -27,7 +26,7 @@ rsync -avh src/site/markdown/overview/changelog.md ${PMD_SF_USER}@web.sourceforg
if [[ "$VERSION" == *-SNAPSHOT && "$TRAVIS_BRANCH" == "master" ]]; then
# Uploading snapshot site...
rsync -avh --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/
rsync -ah --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/
fi

48
.travis/build-site.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
set -ev
# Do not log the output, to avoid the travis log length limit of 4MB
# Solution from http://stackoverflow.com/questions/26082444/how-to-work-around-travis-cis-4mb-output-limit/26082445#26082445
export PING_SLEEP=30s
export BUILD_OUTPUT=/tmp/build-site.out
export PING_PID_FILE=/tmp/build-site-ping.pid
touch $BUILD_OUTPUT
dump_output() {
echo Tailing the last 500 lines of output:
tail -500 $BUILD_OUTPUT
}
kill_ping() {
if [ -e $PING_PID_FILE ]; then
PING_LOOP_PID=$(cat $PING_PID_FILE)
kill $PING_LOOP_PID
rm $PING_PID_FILE
fi
}
error_handler() {
kill_ping
echo ERROR: An error was encountered with the build.
dump_output
exit 1
}
# If an error occurs, run our error handler to output a tail of the build
trap 'error_handler' ERR
# Set up a repeating loop to send some output to Travis.
bash -c "while true; do echo \$(date) - building ...; sleep $PING_SLEEP; done" &
PING_LOOP_PID=$!
echo "$PING_LOOP_PID" > $PING_PID_FILE
# Run the build, redirect output into the file
mvn site site:stage -Psite -B -V >> $BUILD_OUTPUT 2>&1
# The build finished without returning an error so dump a tail of the output
dump_output
# nicely terminate the ping output loop
kill_ping

View File

@ -5,8 +5,8 @@ set -ev
SOURCE_HOME=$PWD
cd $HOME
wget http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar zxvf apache-maven-3.3.9-bin.tar.gz
wget -q http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar zxf apache-maven-3.3.9-bin.tar.gz
chmod +x apache-maven-3.3.9/bin/mvn
echo "MAVEN_OPTS='-Xms1g -Xmx1g'" > .mavenrc