Merge "Configure CSIT Jenkins view"
[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         *csit=*)
17             csit_commit_id=`echo "${i}" | cut -d = -f2-`
18         ;;
19         *)
20         ;;
21     esac
22 done
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
26 if [ -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
39 fi
40
41 # TODO: Add option to build custom VPP and NSH packages
42
43 # Get CSIT branch from which to test from
44 if [ -f csit-test-branch ]; then
45     chmod +x csit-test-branch
46     CSIT_BRANCH=`./csit-test-branch`
47 else
48     CSIT_BRANCH='master'
49 fi
50
51 # Clone csit
52 git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}
53
54 # If the git clone fails, complain clearly and exit
55 if [ $? != 0 ]; then
56     echo "Failed to run: git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}"
57     exit 1
58 fi
59
60 cd csit
61
62 # If CSIT commit ID is given, checkout the specified commit
63 if [ -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
70 fi
71
72 # Download VPP packages
73 if [ ${STREAM} == 'master' ]; then
74     ./resources/tools/scripts/download_hc_build_pkgs.sh ${STREAM} ${OS}
75 else
76     ./resources/tools/scripts/download_hc_build_pkgs.sh 'stable.'${STREAM} ${OS}
77 fi
78
79 cd ${WORKSPACE}