Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cloning via ssh #24

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
14 changes: 12 additions & 2 deletions posix/clone
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,22 @@ fi

if [[ ! -z "${SSH_KEY}" ]]; then
mkdir /root/.ssh
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
printf "${SSH_KEY}" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa

touch /root/.ssh/known_hosts
chmod 600 /root/.ssh/known_hosts
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null

# [email protected]:slinstaedt/drone-plugin-base.git
# DRONE_GIT_SSH_URL=ssh://[email protected]:7999/eproc/eproc-api.git
HOST=$(echo $DRONE_GIT_SSH_URL | sed 's/.*[\/@]\(.*\):.*/\1/')
PORT=$(echo $DRONE_GIT_SSH_URL | sed 's/.*:\(\d*\)\/.*/\1/')
if [[ "$PORT" = "$DRONE_GIT_SSH_URL" ]]; then
ssh-keyscan $HOST > /root/.ssh/known_hosts 2> /dev/null
else
ssh-keyscan -p $PORT $HOST > /root/.ssh/known_hosts 2> /dev/null
fi
export DRONE_REMOTE_URL="$DRONE_GIT_SSH_URL"
fi

# configure git global behavior and parameters via the
Expand Down