365c8e9fdc
Gives the build the best possible chance at passing
27 lines
645 B
Bash
Executable file
27 lines
645 B
Bash
Executable file
#!/bin/sh
|
|
|
|
org="$1"
|
|
repo="$2"
|
|
defbranch="$3"
|
|
|
|
[ -z "$defbranch" ] && defbranch="develop"
|
|
|
|
rm -r "$repo" || true
|
|
|
|
clone() {
|
|
branch=$1
|
|
if [ -n "$branch" ]
|
|
then
|
|
echo "Trying to use the branch $branch"
|
|
git clone https://github.com/$org/$repo.git $repo --branch "$branch" && exit 0
|
|
fi
|
|
}
|
|
|
|
# Try the target branch of the push or PR.
|
|
clone $BUILDKITE_BRANCH
|
|
# Try the PR author's branch in case it exists on the deps as well.
|
|
clone $BUILDKITE_PULL_REQUEST_BASE_BRANCH
|
|
# Try the current branch from Jenkins.
|
|
clone `"echo $GIT_BRANCH" | sed -e 's/^origin\///'`
|
|
# Use the default branch as the last resort.
|
|
clone $defbranch
|