This is a quick fix to attempt to resolve most of the travis failures Most of the failures have been due to transient network failures, that are causing dependency artifact downloads to fail Maven does not have a way to retry this without restarting the whole build, so the mvn dependency plugin is the best bet Unfortunately, running a dependency:resolve on the project returns yet to be compiled dependencies, and causes it to fail... There is an option to excludeGroupIds and excludeArtifactIds in the docs for this goal, but unfortunately they don't seem to work This drafts a dummy pom in a quick and dirty way, just to download all the deps in one go, while retrying for RETRY_COUNT times if it fails

Signed-off-by: Daan Hoogland <daan@onecht.net>
This commit is contained in:
Rafael da Fonseca 2015-06-18 22:04:51 +02:00 committed by Daan Hoogland
parent bbb165a037
commit 880f116a62
2 changed files with 68 additions and 0 deletions

View File

@ -84,3 +84,28 @@ echo -e "\nInstalling some python packages: "
sudo pip install lxml > /dev/null
sudo pip install texttable > /dev/null
#Download project dependencies in a way we can retry if there's a failure, without failing the whole build
RETRY_COUNT=3
#Resolve plugins first
for ((i=0;i<$RETRY_COUNT;i++))
do
mvn org.apache.maven.plugins:maven-dependency-plugin:resolve-plugins
if [[ $? -eq 0 ]]; then
break;
fi
done
#Resolve remaining deps
cd tools/travis
./downloadDeps.sh 2> /dev/null
for ((i=0;i<$RETRY_COUNT;i++))
do
mvn org.apache.maven.plugins:maven-dependency-plugin:resolve
if [[ $? -eq 0 ]]; then
break;
fi
done
cd ../..

43
tools/travis/downloadDeps.sh Executable file
View File

@ -0,0 +1,43 @@
#Create dummy pom
echo '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.apache.cloudstack</groupId><artifactId>travis-build-deps</artifactId><name>Download Deps for Travis CI</name><version>1</version><dependencies>' > pom.xml
#Get all dependency blocks
for line in $(find . -name pom.xml -exec sed -n '/<dependencies>/{:a;n;/<\/dependencies>/b;p;ba}' {} \; | grep -e "artifactId" -e "groupId" -e "version" -e "dependency\>" -e "exclusion\>" -e "exclusions\>"); do
#Tokenize values
set -- $(echo $line | awk -v FS="(>|<)" '{print $2, $3}')
#Start processing data
if [ $1 == "dependency" ]; then
#Create new artifact dep
ARTIFACT=$line
elif [ $1 == "/dependency" ]; then
#Filter out project modules interdependencies and noredist artifacts
if [[ $ARTIFACT != *org.apache.cloudstack* ]] && [[ $ARTIFACT != *com.cloud* ]] && [[ $ARTIFACT != *org.midonet* ]] && [[ $ARTIFACT != *net.juniper* ]] ; then
echo $ARTIFACT$line >> pom.xml
fi
elif [ $1 == "version" ]; then
#If version is a maven var, get the value from parent pom
if [[ $2 == \$\{* ]]; then
VER=$(grep \<$(echo $2 | awk -v FS="(}|{)" '{print $2 }') ../../pom.xml | awk -v FS="(>|<)" '{print $3}')
if [[ "$VER" == "" ]]; then
ARTIFACT=org.apache.cloudstack
else
ARTIFACT="$ARTIFACT<version>$VER</version>"
fi
elif [[ "$2" == "" ]]; then
ARTIFACT="$ARTIFACT<version>LATEST</version>"
else
ARTIFACT=$ARTIFACT$line
fi
else
ARTIFACT=$ARTIFACT$line
fi
done
#Finish dummy pom
echo "</dependencies></project>" >> pom.xml