2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
13 : ${YARDSTICK_REPO:='https://gerrit.opnfv.org/gerrit/yardstick'}
14 : ${YARDSTICK_REPO_DIR:='/home/opnfv/repos/yardstick'}
15 : ${YARDSTICK_BRANCH:='master'} # branch, tag, sha1 or refspec
17 # git update using reference as a branch.
18 # git_update_branch ref
19 function git_update_branch {
22 git checkout -f origin/${git_branch}
23 # a local branch might not exist
24 git branch -D ${git_branch} || true
25 git checkout -b ${git_branch}
28 # git update using reference as a branch.
29 # git_update_remote_branch ref
30 function git_update_remote_branch {
33 git checkout -b ${git_branch} -t origin/${git_branch}
36 # git update using reference as a tag. Be careful editing source at that repo
37 # as working copy will be in a detached mode
39 function git_update_tag {
43 # fetching given tag only
44 git fetch origin tag ${git_tag}
45 git checkout -f ${git_tag}
54 if [[ -n "$(git show-ref refs/tags/${git_ref})" ]]; then
55 git_update_tag "${git_ref}"
56 elif [[ -n "$(git show-ref refs/heads/${git_ref})" ]]; then
57 git_update_branch "${git_ref}"
58 elif [[ -n "$(git show-ref refs/remotes/origin/${git_ref})" ]]; then
59 git_update_remote_branch "${git_ref}"
60 # check to see if it is a remote ref
61 elif git fetch --tags origin "${git_ref}"; then
63 git checkout FETCH_HEAD
65 # if we are a random commit id we have to unshallow
66 # to get all the commits
67 git fetch --unshallow origin
68 git checkout -f "${git_ref}"
72 # releng is not needed, we bind-mount the credentials
75 echo "INFO: Updating yardstick -> ${YARDSTICK_BRANCH}"
76 if [ ! -d ${YARDSTICK_REPO_DIR} ]; then
77 git clone ${YARDSTICK_REPO} ${YARDSTICK_REPO_DIR}
79 cd ${YARDSTICK_REPO_DIR}
80 git_checkout ${YARDSTICK_BRANCH}
82 if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then
83 # setup the environment
84 source ${YARDSTICK_REPO_DIR}/tests/ci/prepare_env.sh
88 ${YARDSTICK_REPO_DIR}/tests/ci/yardstick-verify $@