#!/bin/bash -e

# nothing to do without arguments, show some help
if [[ $# == 0 ]]; then
  echo "You need to pass JOB_NAME and TRIGGER_BUILD_NUMBER as parameters"
  echo "Example:"
  echo ". run_get_artifacts.sh integration-build-mcwarren 1323"
  return
fi
  
REPO=http://jenkins.inconcert/job/$1/$2/artifact/target/artifacts

BIN_ARCHIVE=binaries.tbz
SRC_ARCHIVE=sources.tbz
TESTS_ARCHIVE=tests.tbz
ROCKSD_ARCHIVE=rocksDirectory.tbz

set -x

rm -rf *.tbz
wget -nv $REPO/$SRC_ARCHIVE
wget -nv $REPO/$BIN_ARCHIVE
wget -nv $REPO/$TESTS_ARCHIVE
wget -nv $REPO/$ROCKSD_ARCHIVE

tar xf $SRC_ARCHIVE
tar xf $BIN_ARCHIVE
tar xf $TESTS_ARCHIVE
tar xf $ROCKSD_ARCHIVE

set +x

