fix: use whitespaces instead of tabs
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Markus Pesch 2023-10-01 20:44:02 +02:00
parent 8e901429a3
commit 9fae1f4211
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
4 changed files with 63 additions and 63 deletions

View File

@ -1,17 +1,17 @@
#!/bin/bash #!/bin/bash
if [[ -n "${DRONE_WORKSPACE}" ]]; then if [[ -n "${DRONE_WORKSPACE}" ]]; then
# ensure the unprivileged drone user can write # ensure the unprivileged drone user can write
# to the workspace. This is required because # to the workspace. This is required because
# the workspace is a docker volume and is owned # the workspace is a docker volume and is owned
# by root. # by root.
# sudo mkdir -p ${DRONE_WORKSPACE} # sudo mkdir -p ${DRONE_WORKSPACE}
# sudo chown drone:drone ${DRONE_WORKSPACE} # sudo chown drone:drone ${DRONE_WORKSPACE}
# ensure the workspace is the current working # ensure the workspace is the current working
# directory. This should already be the case, # directory. This should already be the case,
# but we cd just to be safe. # but we cd just to be safe.
cd "${DRONE_WORKSPACE}" || exit 1 cd "${DRONE_WORKSPACE}" || exit 1
fi fi
# force the home directory path. # force the home directory path.
@ -25,7 +25,7 @@ fi
# the netrc file. # the netrc file.
if [[ -n "${DRONE_NETRC_MACHINE}" ]]; then if [[ -n "${DRONE_NETRC_MACHINE}" ]]; then
cat <<EOF > "${HOME}/.netrc" cat <<EOF > "${HOME}/.netrc"
machine ${DRONE_NETRC_MACHINE} machine ${DRONE_NETRC_MACHINE}
login ${DRONE_NETRC_USERNAME} login ${DRONE_NETRC_USERNAME}
password ${DRONE_NETRC_PASSWORD} password ${DRONE_NETRC_PASSWORD}
@ -36,13 +36,13 @@ fi
# the ssh key and add the netrc machine to the # the ssh key and add the netrc machine to the
# known hosts file. # known hosts file.
if [[ -n "${DRONE_SSH_KEY}" ]]; then if [[ -n "${DRONE_SSH_KEY}" ]]; then
mkdir "${HOME}/.ssh" mkdir "${HOME}/.ssh"
echo -n "${DRONE_SSH_KEY}" > "${HOME}/.ssh/id_rsa" echo -n "${DRONE_SSH_KEY}" > "${HOME}/.ssh/id_rsa"
chmod 600 "${HOME}/.ssh/id_rsa" chmod 600 "${HOME}/.ssh/id_rsa"
touch "${HOME}/.ssh/known_hosts" touch "${HOME}/.ssh/known_hosts"
chmod 600 "${HOME}/.ssh/known_hosts" chmod 600 "${HOME}/.ssh/known_hosts"
ssh-keyscan -H "${DRONE_NETRC_MACHINE}" > /etc/ssh/ssh_known_hosts 2> /dev/null ssh-keyscan -H "${DRONE_NETRC_MACHINE}" > /etc/ssh/ssh_known_hosts 2> /dev/null
fi fi
# # AWS codecommit support using AWS access key & secret key # # AWS codecommit support using AWS access key & secret key
@ -62,11 +62,11 @@ fi
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
export DRONE_COMMIT_AUTHOR_NAME=drone export DRONE_COMMIT_AUTHOR_NAME=drone
fi fi
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
fi fi
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME} export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
@ -95,30 +95,30 @@ case ${DRONE_COMMIT_REF} in
esac esac
git_clone_retry(){ git_clone_retry(){
retries="${PLUGIN_RETRIES:-0}" retries="${PLUGIN_RETRIES:-0}"
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2 echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
exit 1 exit 1
fi fi
echo "Cloning with ${retries} retries" echo "Cloning with ${retries} retries"
n=0 n=0
until [ "$n" -gt "${retries}" ]; do until [ "$n" -gt "${retries}" ]; do
$1 && return $1 && return
n=$((n+1)) n=$((n+1))
done done
exit 1 exit 1
} }
case ${CLONE_TYPE} in case ${CLONE_TYPE} in
pull_request) pull_request)
git_clone_retry clone-pull-request git_clone_retry clone-pull-request
;; ;;
tag) tag)
git_clone_retry clone-tag git_clone_retry clone-tag
;; ;;
*) *)
git_clone_retry clone-commit git_clone_retry clone-commit
;; ;;
esac esac

View File

@ -1,15 +1,18 @@
#!/bin/bash #!/bin/bash
set -e
set -x set -x
FLAGS="" GIT_FETCH_ARGS=""
GIT_CHECKOUT_ARGS=""
if [[ -n "${PLUGIN_DEPTH}" ]]; then if [[ -n "${PLUGIN_DEPTH}" ]]; then
FLAGS="--depth=${PLUGIN_DEPTH}" GIT_FETCH_ARGS="${GIT_FETCH_ARGS} --depth=${PLUGIN_DEPTH}"
fi fi
if [ ! -d .git ]; then if [ ! -d .git ]; then
git init git init
git remote add origin "${DRONE_REMOTE_URL}" git remote add origin "${DRONE_REMOTE_URL}"
fi fi
# the branch may be empty for certain event types, # the branch may be empty for certain event types,
@ -18,28 +21,25 @@ fi
# we intentially omit depth flags to avoid failed # we intentially omit depth flags to avoid failed
# clones due to lack of history. # clones due to lack of history.
if [[ -z "${DRONE_COMMIT_BRANCH}" ]] && [[ -n "${DRONE_COMMIT_SHA}" ]]; then if [[ -z "${DRONE_COMMIT_BRANCH}" ]] && [[ -n "${DRONE_COMMIT_SHA}" ]]; then
set -e GIT_CHECKOUT_ARGS="${GIT_CHECKOUT_ARGS} --quiet --force ${DRONE_COMMIT_SHA}"
set -x GIT_FETCH_ARGS="${GIT_FETCH_ARGS} origin"
git fetch origin
git checkout --quiet --force "${DRONE_COMMIT_SHA}"
exit 0
fi fi
# the commit sha may be empty for builds that are # the commit sha may be empty for builds that are
# manually triggered in Harness CI Enterprise. If # manually triggered in Harness CI Enterprise. If
# the commit is empty we clone the branch. # the commit is empty we clone the branch.
if [[ -n "${DRONE_COMMIT_BRANCH}" ]] && [[ -z "${DRONE_COMMIT_SHA}" ]]; then if [[ -n "${DRONE_COMMIT_BRANCH}" ]] && [[ -z "${DRONE_COMMIT_SHA}" ]]; then
set -e GIT_CHECKOUT_ARGS="${GIT_CHECKOUT_ARGS} -b ${DRONE_COMMIT_BRANCH} refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
set -x GIT_FETCH_ARGS="${GIT_FETCH_ARGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
git checkout -b "${DRONE_COMMIT_BRANCH}" "refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
exit 0
fi fi
# if the commit sha and branch name not empty, fetch the branch even if a # if the commit sha and branch name not empty, fetch the branch even if a
# fast-forward is not possible. Checkout the specified commit sha which must be # fast-forward is not possible. Checkout the specified commit sha which must be
# part of the branch. # part of the branch.
set -e if [[ -n "${DRONE_COMMIT_BRANCH}" ]] && [[ -n "${DRONE_COMMIT_SHA}" ]]; then
set -x GIT_CHECKOUT_ARGS="${GIT_CHECKOUT_ARGS} -b ${DRONE_COMMIT_SHA} -b refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}" GIT_FETCH_ARGS="${GIT_FETCH_ARGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
git checkout "${DRONE_COMMIT_SHA}" -b "refs/remotes/origin/${DRONE_COMMIT_BRANCH}" fi
git fetch ${GIT_FETCH_ARGS}
git checkout ${GIT_CHECKOUT_ARGS}

View File

@ -2,18 +2,18 @@
FLAGS="" FLAGS=""
if [[ -n "${PLUGIN_DEPTH}" ]]; then if [[ -n "${PLUGIN_DEPTH}" ]]; then
FLAGS="--depth=${PLUGIN_DEPTH}" FLAGS="--depth=${PLUGIN_DEPTH}"
fi fi
if [ ! -d .git ]; then if [ ! -d .git ]; then
git init git init
git remote add origin "${DRONE_REMOTE_URL}" git remote add origin "${DRONE_REMOTE_URL}"
fi fi
set -e set -e
set -x set -x
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:" git fetch ${FLAGS} origin "+refs/heads/${DRONE_COMMIT_BRANCH}:"
git checkout "${DRONE_COMMIT_BRANCH}" git checkout "${DRONE_COMMIT_BRANCH}"
git fetch origin "${DRONE_COMMIT_REF}:" git fetch origin "${DRONE_COMMIT_REF}:"

View File

@ -2,16 +2,16 @@
FLAGS="" FLAGS=""
if [[ -n "${PLUGIN_DEPTH}" ]]; then if [[ -n "${PLUGIN_DEPTH}" ]]; then
FLAGS="--depth=${PLUGIN_DEPTH}" FLAGS="--depth=${PLUGIN_DEPTH}"
fi fi
if [ ! -d .git ]; then if [ ! -d .git ]; then
git init git init
git remote add origin "${DRONE_REMOTE_URL}" git remote add origin "${DRONE_REMOTE_URL}"
fi fi
set -e set -e
set -x set -x
git fetch "${FLAGS}" origin "+refs/tags/${DRONE_TAG}:" git fetch ${FLAGS} origin "+refs/tags/${DRONE_TAG}:"
git checkout --quiet --force FETCH_HEAD git checkout --quiet --force FETCH_HEAD