Merge "Add INFO.yaml verify job"
[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         *jvpp=*)
11             jvpp_commit_id=`echo "${i}" | cut -d = -f2-`
12         ;;
13         *vpp=*)
14             vpp_commit_id=`echo "${i}" | cut -d = -f2-`
15         ;;
16         *nsh_sfc=*)
17             nsh_commit_id=`echo "${i}" | cut -d = -f2-`
18         ;;
19         *csit=*)
20             csit_commit_id=`echo "${i}" | cut -d = -f2-`
21         ;;
22         *)
23         ;;
24     esac
25 done
26
27 # If HC variable is set, clone and build Honeycomb infra from the specified commit
28 # Otherwise skip this step, hc2vpp will use Honeycomb snapshots from Nexus
29 if [[ -n "${hc_commit_id}" ]]; then
30     git clone https://gerrit.fd.io/r/honeycomb
31     cd honeycomb
32     ref=`git ls-remote -q | grep ${hc_commit_id} | awk '{print $2}'`
33     git fetch origin ${ref} && git checkout FETCH_HEAD
34     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}"
35     if [[ $? != 0 ]]; then
36         echo "Honeycomb infra build failed."
37         exit 1
38     fi
39     cd ${WORKSPACE}
40     # Clean up when done. Leftover build files interfere with building hc2vpp.
41     rm -rf honeycomb
42 fi
43
44 # TODO: Add option to build custom VPP and NSH packages
45
46 # Get CSIT branch from which to test from
47 if [[ -f csit-test-branch ]]; then
48     chmod +x csit-test-branch
49     CSIT_BRANCH=`./csit-test-branch`
50 else
51     CSIT_BRANCH='master'
52 fi
53
54 # Clone csit
55 git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}
56
57 # If the git clone fails, complain clearly and exit
58 if [[ $? != 0 ]]; then
59     echo "Failed to run: git clone https://gerrit.fd.io/r/csit --branch ${CSIT_BRANCH}"
60     exit 1
61 fi
62
63 cd csit
64
65 # If CSIT commit ID is given, checkout the specified commit
66 if [[ -n "${csit_commit_id}" ]]; then
67     # Example:
68     # ...
69     # e8f326efebb58e28dacb9ebb653baf95aad1448c refs/changes/08/11808/1
70     # ...
71     ref=`git ls-remote -q | grep ${csit_commit_id} | awk '{print $2}'`
72     git fetch origin ${ref} && git checkout FETCH_HEAD
73 fi
74
75 # Download VPP packages
76 if [[ "1807 1810 1901" =~ .*$STREAM.* ]]; then
77     # add stable prefix for branches which have older version of package download script
78     # This can be removed when support for 1901 branch ends.
79     if [[ -n "${jvpp_commit_id}" ]]; then
80         echo "Error: Specifying jvpp custom commit is not supported for 1807,1810,1901 stable branches"
81         exit 1
82     fi
83     ./resources/tools/scripts/download_hc_build_pkgs.sh 'stable.'${STREAM} ${OS}
84 else
85     # master and 1904+ branches use new package-cloud download script
86     ./resources/tools/scripts/download_hc_build_pkgs.sh ${STREAM} ${OS} ${jvpp_commit_id}
87 fi
88
89 cd ${WORKSPACE}