clone.sh: allow fetching via SSH
Some repos can be cloned via anonymous HTTP, but fetching specific
branches on them requires SSH auth. Add the FETCH_SSH build parameter to
signal to use SSH when fetching branches.
Change-Id: Ic827d63cb0aa0486a0a3cb629e4dc823964a720e
Signed-off-by: Zachary Leaf <zachary.leaf@arm.com>
diff --git a/scripts/clone.sh b/scripts/clone.sh
index 5246ee1..511f233 100755
--- a/scripts/clone.sh
+++ b/scripts/clone.sh
@@ -101,6 +101,7 @@
REPO_DEFAULT_REFSPEC="$(echo "${repo}" | awk -F ';' '{print $4}')"
REPO_URL="${REPO_HOST}/${REPO_PROJECT}"
REPO_REFSPEC="${REPO_DEFAULT_REFSPEC}"
+ REPO_SSH_URL="ssh://${CI_BOT_USERNAME}@${REPO_HOST#https://}:29418/${REPO_PROJECT}"
# clone and checkout in case it does not exist
if [ ! -d ${SHARE_FOLDER}/${REPO_NAME} ]; then
@@ -120,7 +121,13 @@
# fetch and checkout the corresponding refspec
cd ${SHARE_FOLDER}/${REPO_NAME}
- git fetch ${REPO_URL} ${REPO_REFSPEC}
+
+ if [[ ${FETCH_SSH} ]]; then
+ GIT_SSH_COMMAND="ssh ${SSH_PARAMS}" git fetch ${REPO_SSH_URL} ${REPO_REFSPEC}
+ else
+ git fetch ${REPO_URL} ${REPO_REFSPEC}
+ fi
+
git checkout FETCH_HEAD
echo "Freshly cloned ${REPO_URL} (refspec ${REPO_REFSPEC}):"
git log -1