We have a locally hosted Gitlab repository which I am trying to automate pushing and pulling with gitpython over ssh with the following script:
LOCAL_REPO_PATH = "/path/to/repository"
repo = Repo(LOCAL_REPO_PATH)
origin = repo.remotes[0]
origin.pull()
# Do some automated changes
index = repo.index
index.add(["*"])
index.commit("Removed/Added stuff")
author = Actor("Script","it@place.com)
committer = Actor("Script","it@place.com)
origin.push()
The config of the repo is
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@gitlab.<repo url>:<owner username>/<repository name>.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Whenever I try to run it, it reaches origin.pull() and stops execution to ask for git@gitlab.place.com in the following format:
Password:
Password:
Password:
git@gitlab.<url>'s password:
git@gitlab.<url>'s password:
git@gitlab.<url>'s password:
After incorrectly entering a password 6 times, it throws this error
Traceback (most recent call last):
File "git-test.py", line 15, in <module>
origin.pull()
File "/usr/local/lib/python3.8/dist-packages/git/remote.py", line 910, in pull
res = self._get_fetch_info_from_stderr(proc, progress,
File "/usr/local/lib/python3.8/dist-packages/git/remote.py", line 750, in _get_fetch_info_from_stderr
proc.wait(stderr=stderr_text)
File "/usr/local/lib/python3.8/dist-packages/git/cmd.py", line 502, in wait
raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git pull -v origin
stderr: 'fatal: Could not read from remote repository.'
Is there any way to be able to automate this without having the password for the git user?
Edit 1
I have asked a new question here, as I have closer narrowed down what the issue is.