Skip to content

Commit

Permalink
Added logic to find for a valid drake binary URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Pojomovsky committed May 10, 2018
1 parent 1d25131 commit 379c3d3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
42 changes: 39 additions & 3 deletions tools/continuous_integration/jenkins/build
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/continuous_integration/jenkins/setup_early
Original file line number Diff line number Diff line change
Expand Up @@ -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' ' ' <<EOF
awscli
curl
git
libignition-cmake-dev
mercurial
pkg-config
python3-vcstool
wget
EOF
)

0 comments on commit 379c3d3

Please sign in to comment.