2018-05-02 12:03:40 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
org="$1"
|
|
|
|
repo="$2"
|
2018-12-22 03:16:37 +01:00
|
|
|
defbranch="$3"
|
|
|
|
|
|
|
|
[ -z "$defbranch" ] && defbranch="develop"
|
2018-05-02 12:03:40 +02:00
|
|
|
|
2018-05-02 17:49:08 +02:00
|
|
|
rm -r "$repo" || true
|
|
|
|
|
2018-12-20 23:13:40 +01:00
|
|
|
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
|
|
|
|
}
|
2018-05-02 16:53:38 +02:00
|
|
|
|
2018-12-20 23:13:40 +01:00
|
|
|
# Try the target branch of the push or PR.
|
2019-03-14 05:22:36 +01:00
|
|
|
clone $BUILDKITE_BRANCH
|
2018-12-20 23:13:40 +01:00
|
|
|
# Try the current branch from Jenkins.
|
|
|
|
clone `"echo $GIT_BRANCH" | sed -e 's/^origin\///'`
|
2019-01-04 00:00:23 +01:00
|
|
|
# Use the default branch as the last resort.
|
|
|
|
clone $defbranch
|