From a9a4b1c44e6a9cebceeb5a039c45a01f2f8c0d9e Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 18 May 2017 11:05:19 +0100 Subject: [PATCH] Get branch from various CI env vars So we hopefully get the right branch for PRs from the same repo (but not forks). From @t3chguy's comment (tweaked a bit) --- scripts/fetch-develop.deps.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index 50c3af1a..8048d4bc 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -6,7 +6,22 @@ # the branch the current checkout is on, use that branch. Otherwise, # use develop. -curbranch=`git rev-parse --abbrev-ref HEAD` +# Look in the many different CI env vars for which branch we're +# building +if [[ "$TRAVIS" == true ]]; then + curbranch="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" +else + # ghprbSourceBranch for jenkins github pull request builder + # GIT_BRANCH for other jenkins builds + curbranch="${ghprbSourceBranch:-$GIT_BRANCH}" + # Otherwise look at the actual branch we're on + if [ -z "$curbranch" ] + then + curbranch=`git rev-parse --abbrev-ref HEAD` + fi +fi + +echo "Determined branch to be $curbranch" function dodep() { org=$1