1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#!/bin/sh
WGET_OPTS="-q"
if [ -n "${CI_COMMIT_REF_NAME}" ] ; then
branch="${CI_COMMIT_REF_NAME}"
else
branch=$(git symbolic-ref -q HEAD)
echo "Current ref: ${branch}"
branch=${branch##refs/heads/}
branch=${branch:-master}
echo "Current branch: ${branch}"
fi
commit="$(git rev-parse --short HEAD)"
echo "Current commit: ${commit}"
download()
{
url="$1"
out="$2"
echo "${url} --> ${out} ..."
if wget ${WGET_OPTS} "${url}" -O "${out}" ; then
echo "OK"
exit 0
fi
rm -f "${out}"
echo "FAILED"
}
filename="$1"
if [ -f "${filename}" ] ; then
echo "File ${filename} already downloaded"
exit 0
fi
download "https://download.openpaper.work/data/paperwork/${branch}_${commit}/${filename}" "${filename}"
echo "[FALLBACK]"
download "https://download.openpaper.work/data/paperwork/${branch}_latest/${filename}" "${filename}"
echo "[FALLBACK]"
download "https://download.openpaper.work/data/paperwork/master_latest/${filename}" "${filename}"
echo "FAILED: Unable to download ${filename}"
exit 1
|