From 889b887ebdc7612797f1f0fdcd9d0c87cbfe29b0 Mon Sep 17 00:00:00 2001 From: Jan Gelety Date: Thu, 24 Jan 2019 16:41:20 +0100 Subject: FIX: Checkout csit branch based on BRANCH_ID in vpp-device semiweekly job Change-Id: If5f89f82020c0009d6d2f764526e7006126c2fe9 Signed-off-by: Jan Gelety --- jjb/csit/include-raw-csit-device-semiweekly.sh | 30 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'jjb') diff --git a/jjb/csit/include-raw-csit-device-semiweekly.sh b/jjb/csit/include-raw-csit-device-semiweekly.sh index 0871af69a..b45f7688a 100644 --- a/jjb/csit/include-raw-csit-device-semiweekly.sh +++ b/jjb/csit/include-raw-csit-device-semiweekly.sh @@ -15,15 +15,33 @@ 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" -- cgit 1.2.3-korg