Introduce a global share repository mechanism

This is a full refactor of the way jobs fetch git data: with this
approach, only the top level job, the upstream job, would set a share
folder populated with all required repositories, including
trusted-firmware-a, tf-a-tests, tf-a-job-configs and tf-a-ci-scripts,
ultimately consumed by the builder job, tf-a-builder. This would
reduce considerably the CI build times, avoiding multiple clones per
job thus overloading the TF git servers as reported in [1].

The way it works is simple: the top level job sets the SHARE_FOLDER
parameter based on its name and number on top of the share
volume (/srv/shared/<job name>/<job number>) then it calls the clone
script (clone.sh), which in turn it fetches the repositories mentioned
above. Jobs triggered on behalf of the latter, share the same
SHARE_FOLDER value, and these in turn also call the clone script, but
in this case, the script detects that the folder is already populated so
its role is to simply copy the repositories into the job's
workspace. As seen, all jobs work with repositories on their own
workspace, which are just copies of the share folder, so there is no
change of a race condition, i.e every job works with its own copy. The
worst case scenario is where the down-level job, tf-a-builder, uses its
default SHARE_FOLDER value, in this case, it would simply clone its
own repositories without reusing any file however the current approach
prevents the latter unless the job is triggered manually from the
builder job itself.

Besides the git-cloning strategy presented, the change implied moving
all of jobs to 'docker-amd64-tf-a-bionic' container node, instead of
'master', the former having access to the docker share volume.

[1] https://linaro.atlassian.net/browse/TFC-20

Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
Change-Id: I001bc1148cde4b1952161d84aa3d2e089a4281a2
diff --git a/scripts/clone.sh b/scripts/clone.sh
new file mode 100755
index 0000000..6c88552
--- /dev/null
+++ b/scripts/clone.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2021 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Clones and checkout TF-A related repositories in case these are not present
+# under SHARE_FOLDER, otherwise copy the share repositories into current folder
+# (workspace)
+
+# The way it works is simple: the top level job sets the SHARE_FOLDER
+# parameter based on its name and number on top of the share
+# volume (/srv/shared/<job name>/<job number>) then it calls the clone
+# script (clone.sh), which in turn it fetches the repositories mentioned
+# above. Jobs triggered on behalf of the latter, share the same
+# SHARE_FOLDER value, and these in turn also call the clone script, but
+# in this case, the script detects that the folder is already populated so
+# its role is to simply copy the repositories into the job's
+# workspace. As seen, all jobs work with repositories on their own
+# workspace, which are just copies of the share folder, so there is no
+# change of a race condition, i.e every job works with its own copy. The
+# worst case scenario is where the down-level job, tf-a-builder, uses its
+# default SHARE_FOLDER value, in this case, it would simply clone its
+# own repositories without reusing any file however the current approach
+# prevents the latter unless the job is triggered manually from the
+# builder job itself.
+
+set -e
+
+# Global defaults
+REFSPEC_MASTER="refs/heads/master"
+GIT_REPO="https://git.trustedfirmware.org"
+GERRIT_HOST="https://review.trustedfirmware.org"
+GIT_CLONE_PARAMS="--depth=1 --no-checkout --no-tags"
+
+# Defaults Projects
+TF_GERRIT_PROJECT="${GERRIT_HOST}/${TF_GERRIT_PROJECT:-TF-A/trusted-firmware-a}"
+TFTF_GERRIT_PROJECT="${GERRIT_HOST}/${TFTF_GERRIT_PROJECT:-/TF-A/tf-a-tests}"
+SCRIPTS_PROJECT="${SCRIPTS_PROJECT:-${GIT_REPO}/ci/tf-a-ci-scripts.git}"
+JOBS_PROJECT="${JOB_PROJECT:-${GIT_REPO}/ci/tf-a-job-configs.git}"
+
+# Default Reference specs
+TF_GERRIT_REFSPEC="${TF_GERRIT_REFSPEC:-${REFSPEC_MASTER}}"
+TFTF_GERRIT_REFSPEC="${TFTF_GERRIT_REFSPEC:-${REFSPEC_MASTER}}"
+SCRIPTS_REFSPEC="${SCRIPTS_REFSPEC:-${REFSPEC_MASTER}}"
+JOBS_REFSPEC="${JOBS_REFSPEC:-${REFSPEC_MASTER}}"
+
+# Array containing "<repo url>;"<repo name>;<refspec>" elements
+repos=(
+    "${SCRIPTS_PROJECT};tf-a-ci-scripts;${SCRIPTS_REFSPEC}"
+    "${JOBS_PROJECT};tf-a-job-configs;${JOBS_REFSPEC}"
+    "${TF_GERRIT_PROJECT};trusted-firmware-a;${TF_GERRIT_REFSPEC}"
+    "${TFTF_GERRIT_PROJECT};tf-a-tests;${TFTF_GERRIT_REFSPEC}"
+)
+
+# Take into consideration non-CI runs where SHARE_FOLDER variable
+# may not be present
+if [ -z "${SHARE_FOLDER}" ]; then
+    # Default Jenkins values
+    SHARE_VOLUME="${SHARE_VOLUME:-$PWD}"
+    JOB_NAME="${JOB_NAME:-local}"
+    BUILD_NUMBER="${BUILD_NUMBER:-0}"
+    SHARE_FOLDER=${SHARE_VOLUME}/${JOB_NAME}/${BUILD_NUMBER}
+fi
+
+# clone git repos
+for repo in ${repos[@]}; do
+
+    # parse the repo elements
+    REPO_URL="$(echo "${repo}" | awk -F ';' '{print $1}')"
+    REPO_NAME="$(echo "${repo}" | awk -F ';' '{print $2}')"
+    REPO_REFSPEC="$(echo "${repo}" | awk -F ';' '{print $3}')"
+
+    # clone and checkout in case it does not exit
+    if [ ! -d ${SHARE_FOLDER}/${REPO_NAME} ]; then
+        git clone ${GIT_CLONE_PARAMS} ${REPO_URL} ${SHARE_FOLDER}/${REPO_NAME}
+
+        # fetch and checkout the corresponding refspec
+        cd ${SHARE_FOLDER}/${REPO_NAME}
+        git fetch ${REPO_URL} ${REPO_REFSPEC}
+        git checkout FETCH_HEAD
+        git log -1
+        cd $OLDPWD
+
+    else
+        # otherwise just show the head's log
+        cd ${SHARE_FOLDER}/${REPO_NAME}
+        git log -1
+        cd $OLDPWD
+    fi
+
+    # copy repository into pwd dir (workspace in CI), so each job would work
+    # on its own workspace
+    cp -a -f ${SHARE_FOLDER}/${REPO_NAME} ${PWD}/${REPO_NAME}
+
+done
diff --git a/tf-a-builder.yaml b/tf-a-builder.yaml
index 6753f4e..1f02af5 100644
--- a/tf-a-builder.yaml
+++ b/tf-a-builder.yaml
@@ -1,57 +1,3 @@
-- scm:
-    name: tf-a-ci-scripts
-    scm:
-        - git:
-            url: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git
-            refspec: +refs/heads/master:refs/remotes/origin/master
-            name: origin
-            branches:
-                - refs/heads/master
-            basedir: tf-a-ci-scripts
-            skip-tag: true
-            shallow-clone: true
-            wipe-workspace: false
-- scm:
-    name: tf-a-job-configs
-    scm:
-        - git:
-            url: https://git.trustedfirmware.org/ci/tf-a-job-configs.git
-            refspec: +refs/heads/master:refs/remotes/origin/master
-            name: origin
-            branches:
-                - refs/heads/master
-            basedir: tf-a-job-configs
-            skip-tag: true
-            shallow-clone: true
-            wipe-workspace: false
-- scm:
-    name: trusted-firmware-a
-    scm:
-        - git:
-            url: https://review.trustedfirmware.org/${TF_GERRIT_PROJECT}
-            refspec: ${TF_GERRIT_REFSPEC}
-            name: origin
-            branches:
-                - ${TF_GERRIT_BRANCH}
-            basedir: trusted-firmware-a
-            choosing-strategy: gerrit
-            skip-tag: true
-            shallow-clone: false
-            wipe-workspace: false
-- scm:
-    name: tf-a-tests
-    scm:
-        - git:
-            url: https://review.trustedfirmware.org/${TFTF_GERRIT_PROJECT}
-            refspec: ${TFTF_GERRIT_REFSPEC}
-            name: origin
-            branches:
-                - ${TFTF_GERRIT_BRANCH}
-            basedir: tf-a-tests
-            choosing-strategy: gerrit
-            skip-tag: true
-            shallow-clone: false
-            wipe-workspace: false
 - job:
     name: tf-a-builder
     node: docker-amd64-tf-a-bionic
@@ -125,11 +71,10 @@
         - string:
             name: QA_TOOLS_REPO
             default: 'https://git.gitlab.arm.com/tooling/qa-tools.git'
-    scm:
-        - tf-a-ci-scripts
-        - tf-a-job-configs
-        - trusted-firmware-a
-        - tf-a-tests
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
         - timestamps
         - timeout:
@@ -149,6 +94,8 @@
                 variable: LAVA_TOKEN
     builders:
         - shell:
+            !include-raw: scripts/clone.sh
+        - shell:
             !include-raw: tf-a-builder/builders.sh
         - conditional-step:
             condition-kind: file-exists
diff --git a/tf-ci-gateway.yaml b/tf-ci-gateway.yaml
index ab8b1ef..4539023 100644
--- a/tf-ci-gateway.yaml
+++ b/tf-ci-gateway.yaml
@@ -1,16 +1,3 @@
-- scm:
-    name: tf-a-ci-scripts
-    scm:
-        - git:
-            url: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git
-            refspec: +refs/heads/master:refs/remotes/origin/master
-            name: origin
-            branches:
-                - refs/heads/master
-            basedir: tf-a-ci-scripts
-            skip-tag: true
-            shallow-clone: true
-            wipe-workspace: false
 - job:
     name: tf-ci-gateway
     node: docker-amd64-tf-a-bionic
@@ -53,9 +40,13 @@
     - bool:
         name: ENABLE_STATIC_CHECK
         default: false
-    scm:
-        - tf-a-ci-scripts
+    - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
         #!/bin/bash
         set -e
@@ -63,10 +54,14 @@
         export workspace=$PWD
         export test_groups=$TEST_GROUPS
         $CI_ROOT/script/gen_test_desc.py
+        cat << EOF > share.param
+        SHARE_FOLDER=${SHARE_FOLDER}
+        EOF
     - trigger-builds:
       - project:
         - tf-a-builder
         block: true
+        property-file: share.param
         current-parameters: true
         property-file-fail-on-missing: false
         parameter-factories:
diff --git a/tf-coverity.yaml b/tf-coverity.yaml
index 03d308d..7388121 100644
--- a/tf-coverity.yaml
+++ b/tf-coverity.yaml
@@ -1,30 +1,3 @@
-- scm:
-    name: tf-a-ci-scripts
-    scm:
-        - git:
-            url: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git
-            refspec: +refs/heads/master:refs/remotes/origin/master
-            name: origin
-            branches:
-                - refs/heads/master
-            basedir: tf-a-ci-scripts
-            skip-tag: true
-            shallow-clone: true
-            wipe-workspace: false
-- scm:
-    name: trusted-firmware-a
-    scm:
-        - git:
-            url: https://review.trustedfirmware.org/${TF_GERRIT_PROJECT}
-            refspec: ${TF_GERRIT_REFSPEC}
-            name: origin
-            branches:
-                - ${TF_GERRIT_BRANCH}
-            basedir: trusted-firmware-a
-            choosing-strategy: gerrit
-            skip-tag: true
-            shallow-clone: false
-            wipe-workspace: false
 - job:
     name: tf-coverity
     node: docker-amd64-tf-a-bionic
@@ -58,9 +31,10 @@
         - bool:
             name: UPLOAD_TO_COVERITY_SCAN_ONLINE
             default: false
-    scm:
-        - tf-a-ci-scripts
-        - trusted-firmware-a
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
         - timestamps
         - credentials-binding:
@@ -68,6 +42,8 @@
               credential-id: TF-COVERITY-SCAN-TOKEN
               variable: TF_COVERITY_SCAN_TOKEN
     builders:
+        - shell:
+            !include-raw: scripts/clone.sh
         - shell: |
             #!/bin/bash
             set -e
diff --git a/tf-daily.yaml b/tf-daily.yaml
index 605e865..6897e70 100644
--- a/tf-daily.yaml
+++ b/tf-daily.yaml
@@ -1,6 +1,6 @@
 - job:
     name: tf-daily
-    node: master
+    node: docker-amd64-tf-a-bionic
     project-type: freestyle
     concurrent: false
     disabled: false
@@ -30,9 +30,21 @@
         - string:
             name: TFTF_GERRIT_REFSPEC
             default: '+refs/heads/master:refs/remotes/origin/master'
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
         - timestamps
     builders:
+        - shell:
+            !include-raw: scripts/clone.sh
+        - shell: |
+            #!/bin/bash
+            set -e
+            cat << EOF > share.param
+            SHARE_FOLDER=${SHARE_FOLDER}
+            EOF
         - trigger-builds:
             - project:
                 - tf-main
diff --git a/tf-gerrit-tforg-l1.yaml b/tf-gerrit-tforg-l1.yaml
index f5353e0..58a8568 100644
--- a/tf-gerrit-tforg-l1.yaml
+++ b/tf-gerrit-tforg-l1.yaml
@@ -1,6 +1,6 @@
 - job:
     name: tf-gerrit-tforg-l1
-    node: master
+    node: docker-amd64-tf-a-bionic
     project-type: multijob
     concurrent: true
     disabled: false
@@ -32,6 +32,14 @@
         - string:
             name: GERRIT_CHANGE_NUMBER
             default: ''
+        - string:
+            name: TF_GERRIT_REFSPEC
+            default: ${GERRIT_REFSPEC}
+            description: 'Parameter only used by the clone script'
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
       - credentials-binding:
           - ssh-user-private-key:
@@ -42,6 +50,8 @@
       - workspace-cleanup
       - timestamps
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
         #!/bin/bash
         set -e
@@ -54,6 +64,7 @@
         TF_GERRIT_PROJECT=${GERRIT_PROJECT}
         TF_GERRIT_BRANCH=${GERRIT_BRANCH}
         TF_GERRIT_REFSPEC=${GERRIT_REFSPEC}
+        SHARE_FOLDER=${SHARE_FOLDER}
         EOF
     - multijob:
         name: Lint commit messages
diff --git a/tf-gerrit-tforg-l2.yaml b/tf-gerrit-tforg-l2.yaml
index 9bc8ea6..5dd98d6 100644
--- a/tf-gerrit-tforg-l2.yaml
+++ b/tf-gerrit-tforg-l2.yaml
@@ -1,6 +1,6 @@
 - job:
     name: tf-gerrit-tforg-l2
-    node: master
+    node: docker-amd64-tf-a-bionic
     project-type: multijob
     concurrent: true
     disabled: false
@@ -32,6 +32,14 @@
         - string:
             name: GERRIT_CHANGE_NUMBER
             default: ''
+        - string:
+            name: TF_GERRIT_REFSPEC
+            default: ${GERRIT_REFSPEC}
+            description: 'Parameter only used by the clone script'
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
       - credentials-binding:
           - ssh-user-private-key:
@@ -42,6 +50,8 @@
       - workspace-cleanup
       - timestamps
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
         #!/bin/bash
         set -e
@@ -54,6 +64,7 @@
         TF_GERRIT_PROJECT=${GERRIT_PROJECT}
         TF_GERRIT_BRANCH=${GERRIT_BRANCH}
         TF_GERRIT_REFSPEC=${GERRIT_REFSPEC}
+        SHARE_FOLDER=${SHARE_FOLDER}
         EOF
     - multijob:
         condition: COMPLETED
diff --git a/tf-main.yaml b/tf-main.yaml
index bc14916..dced3e8 100644
--- a/tf-main.yaml
+++ b/tf-main.yaml
@@ -1,33 +1,6 @@
-- scm:
-    name: tf-a-ci-scripts
-    scm:
-        - git:
-            url: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git
-            refspec: +refs/heads/master:refs/remotes/origin/master
-            name: origin
-            branches:
-                - refs/heads/master
-            basedir: tf-a-ci-scripts
-            skip-tag: true
-            shallow-clone: true
-            wipe-workspace: false
-- scm:
-    name: trusted-firmware-a
-    scm:
-        - git:
-            url: https://review.trustedfirmware.org/${TF_GERRIT_PROJECT}
-            refspec: ${TF_GERRIT_REFSPEC}
-            name: origin
-            branches:
-                - ${TF_GERRIT_BRANCH}
-            basedir: trusted-firmware-a
-            choosing-strategy: gerrit
-            skip-tag: true
-            shallow-clone: false
-            wipe-workspace: false
 - job:
     name: tf-main
-    node: master
+    node: docker-amd64-tf-a-bionic
     project-type: multijob
     concurrent: true
     disabled: false
@@ -61,9 +34,10 @@
         - string:
             name: TFTF_GERRIT_REFSPEC
             default: '+refs/heads/master:refs/remotes/origin/master'
-    scm:
-        - tf-a-ci-scripts
-        - trusted-firmware-a
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
       - credentials-binding:
           - ssh-user-private-key:
@@ -74,6 +48,8 @@
       - workspace-cleanup
       - timestamps
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
         #!/bin/bash
         set -e
@@ -83,6 +59,7 @@
         GERRIT_REFSPEC=${TF_GERRIT_REFSPEC}
         QA_SERVER_PROJECT=${JOB_NAME}
         QA_SERVER_VERSION=${BUILD_NUMBER}
+        SHARE_FOLDER=${SHARE_FOLDER}
         EOF
         cat << EOF > tf-a-tests-env.param
         GERRIT_PROJECT=${TFTF_GERRIT_PROJECT}
@@ -90,6 +67,7 @@
         GERRIT_REFSPEC=${TFTF_GERRIT_REFSPEC}
         QA_SERVER_PROJECT=${JOB_NAME}
         QA_SERVER_VERSION=${BUILD_NUMBER}
+        SHARE_FOLDER=${SHARE_FOLDER}
         EOF
     - multijob:
         name: Run static checks on the code
diff --git a/tf-static-checks.yaml b/tf-static-checks.yaml
index 81ab262..4912ef6 100644
--- a/tf-static-checks.yaml
+++ b/tf-static-checks.yaml
@@ -1,44 +1,3 @@
-- scm:
-    name: tf-a-ci-scripts
-    scm:
-        - git:
-            url: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git
-            refspec: +refs/heads/master:refs/remotes/origin/master
-            name: origin
-            branches:
-                - refs/heads/master
-            basedir: tf-a-ci-scripts
-            skip-tag: true
-            shallow-clone: true
-            wipe-workspace: false
-- scm:
-    name: trusted-firmware-a
-    scm:
-        - git:
-            url: https://review.trustedfirmware.org/${TF_GERRIT_PROJECT}
-            refspec: ${TF_GERRIT_REFSPEC}
-            name: origin
-            branches:
-                - ${TF_GERRIT_BRANCH}
-            basedir: trusted-firmware-a
-            choosing-strategy: gerrit
-            skip-tag: true
-            shallow-clone: false
-            wipe-workspace: false
-- scm:
-    name: tf-a-tests
-    scm:
-       - git:
-            url: https://review.trustedfirmware.org/${TFTF_GERRIT_PROJECT}
-            refspec: ${TFTF_GERRIT_REFSPEC}
-            name: origin
-            branches:
-                - ${TFTF_GERRIT_BRANCH}
-            basedir: tf-a-tests
-            choosing-strategy: gerrit
-            skip-tag: true
-            shallow-clone: false
-            wipe-workspace: false
 - job:
     name: tf-static-checks
     node: docker-amd64-tf-a-bionic
@@ -79,16 +38,18 @@
             default: trusted-firmware-a
             description: |-
                 Repository to run static checks on.
-    scm:
-        - tf-a-ci-scripts
-        - trusted-firmware-a
-        - tf-a-tests
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
         - timestamps
         - timeout:
             timeout: 180
             fail: true
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
        #!/bin/bash
        set -e
diff --git a/tf-tftf-gerrit-tforg-l1.yaml b/tf-tftf-gerrit-tforg-l1.yaml
index b57e9d2..e0fa309 100644
--- a/tf-tftf-gerrit-tforg-l1.yaml
+++ b/tf-tftf-gerrit-tforg-l1.yaml
@@ -1,6 +1,6 @@
 - job:
     name: tf-tftf-gerrit-tforg-l1
-    node: master
+    node: docker-amd64-tf-a-bionic
     project-type: multijob
     concurrent: true
     disabled: false
@@ -32,6 +32,14 @@
         - string:
             name: GERRIT_CHANGE_NUMBER
             default: ''
+        - string:
+            name: TFTF_GERRIT_REFSPEC
+            default: ${GERRIT_REFSPEC}
+            description: 'Parameter only used by the clone script'
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
       - credentials-binding:
           - ssh-user-private-key:
@@ -42,6 +50,8 @@
       - workspace-cleanup
       - timestamps
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
         #!/bin/bash
         set -e
@@ -54,6 +64,7 @@
         TFTF_GERRIT_PROJECT=${GERRIT_PROJECT}
         TFTF_GERRIT_BRANCH=${GERRIT_BRANCH}
         TFTF_GERRIT_REFSPEC=${GERRIT_REFSPEC}
+        SHARE_FOLDER=${SHARE_FOLDER}
         EOF
     - multijob:
         condition: COMPLETED
diff --git a/tf-tftf-gerrit-tforg-l2.yaml b/tf-tftf-gerrit-tforg-l2.yaml
index 9741f30..828fee8 100644
--- a/tf-tftf-gerrit-tforg-l2.yaml
+++ b/tf-tftf-gerrit-tforg-l2.yaml
@@ -1,6 +1,6 @@
 - job:
     name: tf-tftf-gerrit-tforg-l2
-    node: master
+    node: docker-amd64-tf-a-bionic
     project-type: multijob
     concurrent: true
     disabled: false
@@ -32,6 +32,14 @@
         - string:
             name: GERRIT_CHANGE_NUMBER
             default: ''
+        - string:
+            name: TFTF_GERRIT_REFSPEC
+            default: ${GERRIT_REFSPEC}
+            description: 'Parameter only used by the clone script'
+        - string:
+            name: SHARE_FOLDER
+            default: '/srv/shared/${JOB_NAME}/${BUILD_NUMBER}'
+            description: 'Folder containing shared repositories for downstream pipeline jobs'
     wrappers:
       - credentials-binding:
           - ssh-user-private-key:
@@ -42,6 +50,8 @@
       - workspace-cleanup
       - timestamps
     builders:
+    - shell:
+        !include-raw: scripts/clone.sh
     - shell: |
         #!/bin/bash
         set -e
@@ -54,6 +64,7 @@
         TFTF_GERRIT_PROJECT=${GERRIT_PROJECT}
         TFTF_GERRIT_BRANCH=${GERRIT_BRANCH}
         TFTF_GERRIT_REFSPEC=${GERRIT_REFSPEC}
+        SHARE_FOLDER=${SHARE_FOLDER}
         EOF
     - multijob:
         condition: COMPLETED