I have configured my CI pipeline to remote via SSH into a server and update the git repository there with the latest changes. However it fails. Because when the CI runs the git pull
command, the response is : "could not read Username for 'https://gitlab.com' "
My question is: Is there a way to run git pull which includes username and password in one single command?
I know the best way is to add the SSH key into gitlab variables to avoid asking for username and password, but that didn't work for me either. so my only option would be to provide username and password.
My gitlab-ci.yml file is like below:
deploy_staging:
stage: deploy
before_script:
- mkdir -p ~/.ssh
- echo -e "$DEPLOY_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh [email protected] "
cd my_Project &&
git pull
"
ssh-add ~/.ssh/id_rsa; ssh -A [email protected] "cd proj && git pull"
. Check - developer.github.com/v3/guides/using-ssh-agent-forwarding – Harish Ved