fix prebuild script in hc2vpp-csit-verify jobs
[ci-management.git] / jjb / hc2vpp / include-raw-hc2vpp-csit-verify-prebuild.sh
1 #!/bin/bash
2 set -xe -o pipefail
3
4 # Parse optional arguments from gerrit comment trigger
5 for 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         *)
17         ;;
18     esac
19 done
20
21 # If HC variable is set, clone and build Honeycomb infra from the specified commit
22 # Otherwise skip this step, hc2vpp will use Honeycomb snapshots from Nexus
23 if [ -n "${hc_commit_id}" ]; then
24     git clone https://gerrit.fd.io/r/honeycomb
25     cd honeycomb
26     ref=`git ls-remote -q | grep ${hc_commit_id} | awk '{print $2}'`
27     git fetch origin ${ref} && git checkout FETCH_HEAD
28     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}"
29     if [ $? != 0 ]; then
30         echo "Honeycomb infra build failed."
31         exit 1
32     fi
33     cd ${WORKSPACE}
34     # Clean up when done. Leftover build files interfere with building hc2vpp.
35     rm -rf honeycomb
36 fi
37
38 # TODO: Add option to build custom VPP and NSH packages
39
40 # Get CSIT branch from which to test from
41 if [ -f csit-test-branch ]; then
42     chmod +x csit-test-branch
43     CSIT_BRANCH=`./csit-test-branch`
44 else
45     CSIT_BRANCH='master'
46 fi
47
48 # Clone csit
49 git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}
50
51 # If the git clone fails, complain clearly and exit
52 if [ $? != 0 ]; then
53     echo "Failed to run: git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}"
54     exit 1
55 fi
56
57 cd csit
58
59 # Download VPP packages
60 if [ ${STREAM} == 'master' ]; then
61     ./resources/tools/scripts/download_hc_build_pkgs.sh ${STREAM} ${OS}
62 else
63     ./resources/tools/scripts/download_hc_build_pkgs.sh 'stable.'${STREAM} ${OS}
64 fi
65
66 cd ${WORKSPACE}