FIX: Checkout csit branch based on BRANCH_ID in vpp-device semiweekly job 62/17062/1
authorJan Gelety <jgelety@cisco.com>
Thu, 24 Jan 2019 15:41:20 +0000 (16:41 +0100)
committerJan Gelety <jgelety@cisco.com>
Thu, 24 Jan 2019 15:41:20 +0000 (16:41 +0100)
Change-Id: If5f89f82020c0009d6d2f764526e7006126c2fe9
Signed-off-by: Jan Gelety <jgelety@cisco.com>
jjb/csit/include-raw-csit-device-semiweekly.sh

index 0871af6..b45f768 100644 (file)
 
 set -exuo pipefail
 
+# Clone CSIT git repository and proceed with entry script located there.
+#
+# Variables read:
+# - WORKSPACE - Jenkins workspace to create csit subdirectory in.
+# - BRANCH_ID - CSIT operational branch to be used for test.
+# Directories updated:
+# - ${WORKSPACE}/csit - Created, holding a checked out CSIT repository.
+# - Multiple other side effects by entry script(s), see CSIT repository.
+
 cd "${WORKSPACE}"
 git clone https://gerrit.fd.io/r/csit --depth=1 --no-single-branch --no-checkout
+# Check BRANCH_ID value.
+if [[ -z "${BRANCH_ID-}" ]]; then
+    echo "BRANCH_ID not provided => 'oper' belonging to master will be used."
+    BRANCH_ID="oper"
+fi
 pushd "${WORKSPACE}/csit"
-if [[ -n "${CSIT_REF-}" ]]; then
-    git fetch --depth=1 https://gerrit.fd.io/r/csit "${CSIT_REF}"
-    git checkout FETCH_HEAD
-else
-    git checkout HEAD
+# Get the latest verified version of the required branch.
+BRANCH_NAME=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
+if [[ -z "${BRANCH_NAME-}" ]]; then
+    echo "No verified CSIT branch found - exiting!"
+    exit 1
 fi
+# Remove 'origin/' from the branch name.
+BRANCH_NAME=$(echo ${BRANCH_NAME#origin/})
+# Checkout the required csit branch.
+git checkout "${BRANCH_NAME}"
 popd
 csit_entry_dir="${WORKSPACE}/csit/resources/libraries/bash/entry"
-source "${csit_entry_dir}/with_oper_for_vpp.sh" "bootstrap_vpp_device.sh"
+source "${csit_entry_dir}/bootstrap_vpp_device.sh"