From 880f116a629c7f00af3ad4af331924edeb585047 Mon Sep 17 00:00:00 2001 From: Rafael da Fonseca Date: Thu, 18 Jun 2015 22:04:51 +0200 Subject: [PATCH] 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 --- tools/travis/before_install.sh | 25 ++++++++++++++++++++ tools/travis/downloadDeps.sh | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 tools/travis/downloadDeps.sh diff --git a/tools/travis/before_install.sh b/tools/travis/before_install.sh index 31efc653609..dd90ec6ad81 100755 --- a/tools/travis/before_install.sh +++ b/tools/travis/before_install.sh @@ -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 ../.. diff --git a/tools/travis/downloadDeps.sh b/tools/travis/downloadDeps.sh new file mode 100755 index 00000000000..29248e0c8b9 --- /dev/null +++ b/tools/travis/downloadDeps.sh @@ -0,0 +1,43 @@ +#Create dummy pom +echo '4.0.0org.apache.cloudstacktravis-build-depsDownload Deps for Travis CI1' > pom.xml + +#Get all dependency blocks +for line in $(find . -name pom.xml -exec sed -n '//{: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$VER" + fi + elif [[ "$2" == "" ]]; then + ARTIFACT="$ARTIFACTLATEST" + else + ARTIFACT=$ARTIFACT$line + fi + else + ARTIFACT=$ARTIFACT$line + fi + +done + + +#Finish dummy pom +echo "" >> pom.xml