Merge "Configure CSIT Jenkins view"
[ci-management.git] / jjb / csit / include-raw-csit-device-semiweekly.sh
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2018 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 set -exuo pipefail
17
18 # Clone CSIT git repository and proceed with entry script located there.
19 #
20 # Variables read:
21 # - WORKSPACE - Jenkins workspace to create csit subdirectory in.
22 # - BRANCH_ID - CSIT operational branch to be used for test.
23 # Directories updated:
24 # - ${WORKSPACE}/csit - Created, holding a checked out CSIT repository.
25 # - Multiple other side effects by entry script(s), see CSIT repository.
26
27 cd "${WORKSPACE}"
28 git clone https://gerrit.fd.io/r/csit --depth=1 --no-single-branch --no-checkout
29 # Check BRANCH_ID value.
30 if [[ -z "${BRANCH_ID-}" ]]; then
31     echo "BRANCH_ID not provided => 'oper' belonging to master will be used."
32     BRANCH_ID="oper"
33 fi
34 pushd "${WORKSPACE}/csit"
35 # Get the latest verified version of the required branch.
36 BRANCH_NAME=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
37 if [[ -z "${BRANCH_NAME-}" ]]; then
38     echo "No verified CSIT branch found - exiting!"
39     exit 1
40 fi
41 # Remove 'origin/' from the branch name.
42 BRANCH_NAME=$(echo ${BRANCH_NAME#origin/})
43 # Checkout the required csit branch.
44 git checkout "${BRANCH_NAME}"
45 popd
46 csit_entry_dir="${WORKSPACE}/csit/resources/libraries/bash/entry"
47 source "${csit_entry_dir}/bootstrap_vpp_device.sh"