From 379c3d3270c5f645ae90013ceedf32b8a4b126d7 Mon Sep 17 00:00:00 2001 From: Alexis Pojomovsky Date: Thu, 10 May 2018 14:57:22 -0300 Subject: [PATCH] Added logic to find for a valid drake binary URL --- tools/continuous_integration/jenkins/build | 42 +++++++++++++++++-- .../jenkins/setup_early | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tools/continuous_integration/jenkins/build b/tools/continuous_integration/jenkins/build index 91e6003b6..ceb34ce3b 100755 --- a/tools/continuous_integration/jenkins/build +++ b/tools/continuous_integration/jenkins/build @@ -7,15 +7,51 @@ COMPILER_PATH="/usr/bin/g++-5" mkdir -p install -# The date that conforms part of the build URL is automatically parsed from the +# The date that forms part of the build URL is automatically parsed from the # drake respository's last commit date, avoiding us from doing it by hand. + pushd workspace/drake COMMIT_DATE="$(git log -n 1 --pretty='format:%cd' --date=format:'%Y%m%d')" popd -BUILD_URL="https://drake-packages.csail.mit.edu/drake/nightly/drake-$COMMIT_DATE-xenial.tar.gz" + +BINARY_URL="https://drake-packages.csail.mit.edu/drake/nightly/drake-$COMMIT_DATE-xenial.tar.gz" + +VALID_URL=false + +url_exists () { + echo Testing URL: $1 + if curl --output /dev/null --silent --head --max-time 5 --fail "$1"; then + VALID_URL=true + fi +} + +url_exists $BINARY_URL + +# In case the initial URL for downloading the binary is not valid, +# the script will attempt to generate new ones based on the dates of up +# to 5 days after the commit date. +if ! $VALID_URL; then + TEST_DATE=$COMMIT_DATE + NUM_ATTEMPTS=1 + while ! $VALID_URL; do + if [ "$NUM_ATTEMPTS" -le "5" ] ; then + # Adds one day to the current date to test. + TEST_DATE=$(date +%Y%m%d -d "$TEST_DATE + 1 day") + # Updates binary's URL with new date. + BINARY_URL="https://drake-packages.csail.mit.edu/drake/nightly/drake-$TEST_DATE-xenial.tar.gz" + # Checks availability. + url_exists $BINARY_URL + NUM_ATTEMPTS=$((NUM_ATTEMPTS+1)) + # If couldn't find a valid URL between the tested dates, fails. + else + echo "ERROR: Couldn't find a valid URL to download drake binaries." + exit 1 + fi + done +fi # Downloads drake binary and untars it into the install directory. -wget -qO- $BUILD_URL | tar xvz -C `pwd`/install --strip 1 +curl $BINARY_URL | tar xvz -C `pwd`/install --strip 1 mkdir -p build diff --git a/tools/continuous_integration/jenkins/setup_early b/tools/continuous_integration/jenkins/setup_early index e57bc93ee..b92663afe 100755 --- a/tools/continuous_integration/jenkins/setup_early +++ b/tools/continuous_integration/jenkins/setup_early @@ -16,11 +16,11 @@ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C sudo apt-get update -qq sudo apt-get install -y --no-install-recommends $(tr '\n' ' ' <