drone/app/gitspace/orchestrator/template/templates/authenticate_git.sh
Ansuman Satapathy f7928f1f77 feat: [CDE-195]: autoset git user config for internal repos (#2304)
* feat: [CDE-195]: autoset git user config for internal repos
2024-07-29 06:52:07 +00:00

18 lines
496 B
Bash

#!/bin/sh
name={{ .Name }}
password={{ .Password }}
email={{ .Email }}
# Create or overwrite the config file with new settings
touch $HOME/.git-askpass
cat > $HOME/.git-askpass <<EOF
echo $password
EOF
chmod 700 $HOME/.git-askpass
git config --global credential.helper 'cache --timeout=2592000'
git config --global user.email $email
git config --global user.name $name
#run git operation to cache the credential in memory
export GIT_ASKPASS=$HOME/.git-askpass
git ls-remote
rm $HOME/.git-askpass