ci: accommodate for repo name to be part of `GIT_BRANCH`

It seems that that variable is set by the git jenkins plugin and it's format is `origin/master`. See https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables

Original commit: elastic/x-pack-elasticsearch@17f8ec1a9e
This commit is contained in:
Boaz Leskes 2016-12-06 09:43:28 +01:00
parent 7483abb226
commit 373c350920
1 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,8 @@ if [ -z ${USE_EXISTING_ES:+x} ]; then
exit 1
fi
# AWAITSFIX: the fallback to master should be removed, see https://github.com/elastic/infra/issues/1557
BRANCH=${PR_SOURCE_BRANCH:-${GIT_BRANCH:-master}} # fall back to CI branch if not testing a PR
BRANCH=${PR_SOURCE_BRANCH:-${GIT_BRANCH#/}} # GIT_BRANCH starts with the repo, i.e., origin/master
BRANCH=${BRANCH:-master} # fall back to CI branch if not testing a PR
echo "Checking if branch '$BRANCH' has elasticsearch sibling..."
if [[ -z "$(git ls-remote --heads git@github.com:elastic/elasticsearch.git $BRANCH)" ]]; then
echo "No sibling branch, using PR target branch"