include-raw-hc2vpp-csit-verify-prebuild.sh revision d413dc36
1#!/bin/bash
2set -xe -o pipefail
3
4# Parse optional arguments from gerrit comment trigger
5for i in ${GERRIT_EVENT_COMMENT_TEXT}; do
6    case ${i} in
7        *honeycomb=*)
8            hc_commit_id=`echo "${i}" | cut -d = -f2-`
9        ;;
10        *vpp=*)
11            vpp_commit_id=`echo "${i}" | cut -d = -f2-`
12        ;;
13        *nsh_sfc=*)
14            nsh_commit_id=`echo "${i}" | cut -d = -f2-`
15        ;;
16        *csit=*)
17            csit_commit_id=`echo "${i}" | cut -d = -f2-`
18        ;;
19        *)
20        ;;
21    esac
22done
23
24# If HC variable is set, clone and build Honeycomb infra from the specified commit
25# Otherwise skip this step, hc2vpp will use Honeycomb snapshots from Nexus
26if [[ -n "${hc_commit_id}" ]]; then
27    git clone https://gerrit.fd.io/r/honeycomb
28    cd honeycomb
29    ref=`git ls-remote -q | grep ${hc_commit_id} | awk '{print $2}'`
30    git fetch origin ${ref} && git checkout FETCH_HEAD
31    mvn clean install -DskipTests -Dcheckstyle.skip -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r -gs "${GLOBAL_SETTINGS_FILE}" -s "${SETTINGS_FILE}"
32    if [[ $? != 0 ]]; then
33        echo "Honeycomb infra build failed."
34        exit 1
35    fi
36    cd ${WORKSPACE}
37    # Clean up when done. Leftover build files interfere with building hc2vpp.
38    rm -rf honeycomb
39fi
40
41# TODO: Add option to build custom VPP and NSH packages
42
43# Get CSIT branch from which to test from
44if [[ -f csit-test-branch ]]; then
45    chmod +x csit-test-branch
46    CSIT_BRANCH=`./csit-test-branch`
47else
48    CSIT_BRANCH='master'
49fi
50
51# Clone csit
52git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}
53
54# If the git clone fails, complain clearly and exit
55if [[ $? != 0 ]]; then
56    echo "Failed to run: git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}"
57    exit 1
58fi
59
60cd csit
61
62# If CSIT commit ID is given, checkout the specified commit
63if [[ -n "${csit_commit_id}" ]]; then
64    # Example:
65    # ...
66    # e8f326efebb58e28dacb9ebb653baf95aad1448c refs/changes/08/11808/1
67    # ...
68    ref=`git ls-remote -q | grep ${csit_commit_id} | awk '{print $2}'`
69    git fetch origin ${ref} && git checkout FETCH_HEAD
70fi
71
72# Download VPP packages
73./resources/tools/scripts/download_hc_build_pkgs.sh ${STREAM} ${OS}l
74
75
76cd ${WORKSPACE}
77