Global: Rework archive artifacts
[ci-management.git] / jjb / scripts / csit / device-semiweekly.sh
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2020 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 echo "---> jjb/scripts/csit/device-semiweekly.sh"
17
18 set -exuo pipefail
19
20 # Clone CSIT git repository and proceed with entry script located there.
21 #
22 # Variables read:
23 # - WORKSPACE - Jenkins workspace to create csit subdirectory in.
24 # - BRANCH_ID - CSIT operational branch to be used for test.
25 # Directories updated:
26 # - ${WORKSPACE}/csit - Created, holding a checked out CSIT repository.
27 # - Multiple other side effects by entry script(s), see CSIT repository.
28
29 cd "${WORKSPACE}"
30 git clone https://gerrit.fd.io/r/csit --depth=1 --no-single-branch --no-checkout
31 # Check BRANCH_ID value.
32 if [[ -z "${BRANCH_ID-}" ]]; then
33     echo "BRANCH_ID not provided => 'oper' belonging to master will be used."
34     BRANCH_ID="oper"
35 fi
36 pushd "${WORKSPACE}/csit"
37 # Get the latest verified version of the required branch.
38 BRANCH_NAME=$(echo $(git branch -r | grep -E "${BRANCH_ID}-[0-9]+" | tail -n 1))
39 if [[ -z "${BRANCH_NAME-}" ]]; then
40     echo "No verified CSIT branch found - exiting!"
41     exit 1
42 fi
43 # Remove 'origin/' from the branch name.
44 BRANCH_NAME=$(echo ${BRANCH_NAME#origin/})
45 # Checkout the required csit branch.
46 git checkout "${BRANCH_NAME}"
47 popd
48 csit_entry_dir="${WORKSPACE}/csit/resources/libraries/bash/entry"
49 source "${csit_entry_dir}/bootstrap_vpp_device.sh"
50 cp -R "${WORKSPACE}/csit/archives" "${WORKSPACE}/archives" || true