Merge "CSIT-797 Add honeycomb parameter to hc2vpp-csit-verify job"
[ci-management.git] / jjb / hc2vpp / include-raw-hc2vpp-csit-verify-prebuild.sh
1 #!/bin/bash
2 set -xeu -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
29     if [ $? != 0 ]; then
30         echo "Honeycomb infra build failed."
31         exit 1
32     fi
33     cd ${WORKSPACE}
34 fi
35
36 # TODO: Add option to build custom VPP and NSH packages
37
38 # Get CSIT branch from which to test from
39 if [ -f csit-test-branch ]; then
40     chmod +x csit-test-branch
41     CSIT_BRANCH=`./csit-test-branch`
42 else
43     CSIT_BRANCH='master'
44 fi
45
46 # Clone csit
47 git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}
48
49 # If the git clone fails, complain clearly and exit
50 if [ $? != 0 ]; then
51     echo "Failed to run: git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}"
52     exit 1
53 fi
54
55 cd csit
56
57 # Download VPP packages
58 if [ ${STREAM} == 'master' ]; then
59     ./resources/tools/scripts/download_hc_build_pkgs.sh ${STREAM} ${OS}
60 else
61     ./resources/tools/scripts/download_hc_build_pkgs.sh 'stable.'${STREAM} ${OS}
62 fi
63
64 cd ${WORKSPACE}