Merge "CSIT-682 Usage of make-verify for vpp-csit-verify jobs"
[ci-management.git] / jjb / csit / include-raw-csit-vpp-verify-nightly.sh
1 #!/bin/bash
2 set -xeu -o pipefail
3
4 # check BRANCH_ID value
5 if [ "$BRANCH_ID" == "" ]; then
6     echo "branch_id not provided => 'master' will be used"
7     BRANCH_ID="master"
8 fi
9
10 # clone csit
11 git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit
12
13 # if the git clone fails, complain clearly and exit
14 if [ $? != 0 ]; then
15     echo "Failed to run: git clone --depth 1 --no-single-branch https://gerrit.fd.io/r/csit"
16     exit 1
17 fi
18
19 cd csit
20
21 # get the latest verified version of the required branch
22 BRANCH_NAME=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
23
24 if [ "${BRANCH_NAME}" == "" ]; then
25     echo "No verified version found for requested branch - exiting"
26     exit 1
27 fi
28
29 # remove 'origin/' from the branch name
30 BRANCH_NAME=$(echo ${BRANCH_NAME#origin/})
31
32 # checkout to the required branch
33 git checkout ${BRANCH_NAME}
34
35 # execute csit bootstrap script if it exists
36 if [ -e bootstrap-vpp-verify-nightly.sh ]
37 then
38     # make sure that bootstrap.sh is executable
39     chmod +x bootstrap-vpp-verify-nightly.sh
40     # run the script
41     ./bootstrap-vpp-verify-nightly.sh
42 else
43     echo 'ERROR: No bootstrap-vpp-verify-nightly.sh found'
44     exit 1
45 fi
46
47 # vim: ts=4 ts=4 sts=4 et :