Add option to clone CI from OpenCI repository

To test patches submitted to OpenCI, a Jenkins job is created
here (https://gerrit.oss.arm.com/172749) that uses OpenCI
instead of Arm internal CI. This patch adds the necessary
modifications to be able to clone and checkout patches from
OpenCI when needed.

By default the internal CI is used. Alternatively OpenCI
can be used by specifying the new CI_SRC_REPO_URL parameter
when launching a tf-ci-gateway job.

Change-Id: I9378da1a3f7820033c5f8916fd2caa4542550c3e
Signed-off-by: Zelalem <zelalem.aweke@arm.com>
diff --git a/script/scratch_scripts/initial_clone_v2.6.sh b/script/scratch_scripts/initial_clone_v2.6.sh
index ebcfbd2..146bd70 100755
--- a/script/scratch_scripts/initial_clone_v2.6.sh
+++ b/script/scratch_scripts/initial_clone_v2.6.sh
@@ -20,6 +20,15 @@
 
 set -e
 
+arm_gerrit_url="gerrit.oss.arm.com"
+tforg_gerrit_url="review.trustedfirmware.org"
+ci_url="${https://$arm_gerrit_url/pdswinf/ci/pdcs-platforms/platform-ci:-$CI_SRC_REPO_URL}"
+gerrit_server="arm"
+
+if [ "$ci_url" == *${tforg_gerrit_url}* ];then
+        gerrit_server="tforg"
+fi
+
 strip_var() {
 	local var="$1"
 	local val="$(echo "${!var}" | sed 's#^\s*\|\s*$##g')"
@@ -105,7 +114,7 @@
 then
 git clone -q --depth 1 \
 	--reference /arm/projectscratch/ssg/trusted-fw/ref-repos/trusted-firmware-ci \
-	https://gerrit.oss.arm.com/pdswinf/ci/pdcs-platforms/platform-ci
+	$ci_url platform-ci
 else
 	pushd platform-ci
 	git fetch
@@ -130,7 +139,7 @@
 	# Translate refspec if supported
 	if [ -x "$ci_root/script/translate_refspec.py" ]; then
 		CI_REFSPEC="$("$ci_root/script/translate_refspec.py" \
-				-p trusted-firmware-ci -s arm "$CI_REFSPEC")"
+				-p trusted-firmware-ci -s $gerrit_server "$CI_REFSPEC")"
 	fi
 
 	pushd platform-ci &>/dev/null
diff --git a/script/translate_refspec.py b/script/translate_refspec.py
index 567f706..eba7844 100755
--- a/script/translate_refspec.py
+++ b/script/translate_refspec.py
@@ -35,6 +35,7 @@
     "tforg": {
         "trusted-firmware": gerrit.GerritProject("TF-A/trusted-firmware-a", gerrit_tforg),
         "trusted-firmware-tf": gerrit.GerritProject("TF-A/tf-a-tests", gerrit_tforg),
+        "trusted-firmware-ci": gerrit.GerritProject("ci/tf-a-ci-scripts", gerrit_tforg),
     },
 }